diff --git a/CHANGELOG.md b/CHANGELOG.md index b97b2c7..bd317f2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,13 @@ [English](CHANGELOG_EN.md) | 中文 +## v1.8.6-fix1 + +- 修复 AnimatorParameterDriverManager 中的随机整数生成逻辑 +- 修正 AnimatorParameterDriverManager 中随机整数生成的范围,确保包含最大值 +- 修正复制参数操作的范围转换逻辑 +- 更新 ModelParameterDriver 和 BlueprintID 组件的文档注释,增强可读性和理解性 + ## v1.8.6 - 新增 `ModelParameterDriver` 组件,支持在动画状态机中自定义参数控制 diff --git a/CHANGELOG_EN.md b/CHANGELOG_EN.md index 4c02aa1..fd2b97b 100644 --- a/CHANGELOG_EN.md +++ b/CHANGELOG_EN.md @@ -2,6 +2,13 @@ English | [中文](CHANGELOG.md) +## v1.8.6-fix1 + +- Fixed random integer generation logic in AnimatorParameterDriverManager +- Fixed random integer generation range in AnimatorParameterDriverManager to ensure maximum value is included +- Fixed range conversion logic for copy parameter operation +- Updated documentation comments for ModelParameterDriver and BlueprintID components to improve readability and understanding + ## v1.8.6 - Added `ModelParameterDriver` component, supporting custom parameter control in animation state machines diff --git a/DuckovCustomModel.Core/Managers/AnimatorParameterDriverManager.cs b/DuckovCustomModel.Core/Managers/AnimatorParameterDriverManager.cs index 34b1f85..65f74be 100644 --- a/DuckovCustomModel.Core/Managers/AnimatorParameterDriverManager.cs +++ b/DuckovCustomModel.Core/Managers/AnimatorParameterDriverManager.cs @@ -131,7 +131,7 @@ private static void ApplyParameterAsRandom(ModelParameterDriver.Parameter parame animator.SetFloat(targetParam.name, randomFloat); break; case AnimatorControllerParameterType.Int: - var randomInt = Random.Range((int)parameter.valueMin, (int)parameter.valueMax); + var randomInt = Random.Range((int)parameter.valueMin, (int)parameter.valueMax + 1); animator.SetInteger(targetParam.name, randomInt); break; case AnimatorControllerParameterType.Bool: @@ -169,10 +169,10 @@ private static void ApplyParameterAsCopy(ModelParameterDriver.Parameter paramete { var sourceMin = parameter.sourceMin; var sourceMax = parameter.sourceMax; - var targetMin = parameter.valueMin; - var targetMax = parameter.valueMax; + var targetMin = parameter.destMin; + var targetMax = parameter.destMax; - if (sourceMax - sourceMin != 0) + if (Mathf.Abs(sourceMax - sourceMin) > Mathf.Epsilon) finalValue = targetMin + (sourceValue - sourceMin) * (targetMax - targetMin) / (sourceMax - sourceMin); } diff --git a/DuckovCustomModel.Core/MonoBehaviours/Animators/ModelParameterDriver.cs b/DuckovCustomModel.Core/MonoBehaviours/Animators/ModelParameterDriver.cs index 4a351d0..afb3d13 100644 --- a/DuckovCustomModel.Core/MonoBehaviours/Animators/ModelParameterDriver.cs +++ b/DuckovCustomModel.Core/MonoBehaviours/Animators/ModelParameterDriver.cs @@ -5,6 +5,13 @@ namespace DuckovCustomModel.Core.MonoBehaviours.Animators { + /// + /// Drives animator parameters when animation states are entered, similar to Unity's built-in Animator Parameter + /// Driver. + /// Attach this component to animation state machine states to automatically set, add, randomize, or copy animator + /// parameters + /// when the state is entered. Useful for controlling complex animation logic and parameter changes in a modular way. + /// public class ModelParameterDriver : StateMachineBehaviour, ISerializationCallbackReceiver { public enum ChangeType @@ -84,7 +91,18 @@ public class Parameter public float destMin; public float destMax; + /// + /// Runtime-only cached reference to the destination parameter. + /// Populated during initialization for performance optimization. + /// Not intended to be set manually or serialized. + /// public object? DestParam; + + /// + /// Runtime-only cached reference to the source parameter. + /// Populated during initialization for performance optimization. + /// Not intended to be set manually or serialized. + /// public object? SourceParam; } } diff --git a/DuckovCustomModel.Core/MonoBehaviours/Packages/BlueprintID.cs b/DuckovCustomModel.Core/MonoBehaviours/Packages/BlueprintID.cs index ca1d5e0..29f7e51 100644 --- a/DuckovCustomModel.Core/MonoBehaviours/Packages/BlueprintID.cs +++ b/DuckovCustomModel.Core/MonoBehaviours/Packages/BlueprintID.cs @@ -3,10 +3,14 @@ namespace DuckovCustomModel.Core.MonoBehaviours.Packages { + /// + /// Assigns unique identifiers to game objects. Currently a placeholder for future functionality. + /// [AddComponentMenu("Duckov Custom Model/Blueprint ID")] [DisallowMultipleComponent] public class BlueprintID : MonoBehaviour { + [Tooltip("Unique identifier for this game object")] public string id = string.Empty; [ContextMenu("Generate New ID")] diff --git a/DuckovCustomModel/Constant.cs b/DuckovCustomModel/Constant.cs index c4c479d..91abb1c 100644 --- a/DuckovCustomModel/Constant.cs +++ b/DuckovCustomModel/Constant.cs @@ -4,7 +4,7 @@ public static class Constant { public const string ModID = "DuckovCustomModel"; public const string ModName = "Duckov Custom Model"; - public const string ModVersion = "1.8.6"; + public const string ModVersion = "1.8.6-fix1"; public const string HarmonyId = "com.ritsukage.DuckovCustomModel"; } }