From 0a40427ea6202315686a82ee6005ff5bb7fe528c Mon Sep 17 00:00:00 2001 From: OLC Date: Fri, 21 Nov 2025 18:14:43 +0800 Subject: [PATCH 1/2] =?UTF-8?q?fix:=20=E6=9B=B4=E6=96=B0=E7=89=88=E6=9C=AC?= =?UTF-8?q?=E5=8F=B7=E8=87=B3=201.8.6-fix1=EF=BC=8C=E5=B9=B6=E4=BF=AE?= =?UTF-8?q?=E5=A4=8D=20AnimatorParameterDriverManager=20=E4=B8=AD=E7=9A=84?= =?UTF-8?q?=E9=9A=8F=E6=9C=BA=E6=95=B4=E6=95=B0=E7=94=9F=E6=88=90=E9=80=BB?= =?UTF-8?q?=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 修改 ModVersion 为 1.8.6-fix1 - 修正 AnimatorParameterDriverManager 中随机整数生成的范围,确保包含最大值 - 更新 ModelParameterDriver 和 BlueprintID 组件的文档注释,增强可读性和理解性 --- .../Managers/AnimatorParameterDriverManager.cs | 8 ++++---- .../Animators/ModelParameterDriver.cs | 18 ++++++++++++++++++ .../MonoBehaviours/Packages/BlueprintID.cs | 4 ++++ DuckovCustomModel/Constant.cs | 2 +- 4 files changed, 27 insertions(+), 5 deletions(-) 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"; } } From be728ba6d260257f42790928f8eaa3d0bc3e1527 Mon Sep 17 00:00:00 2001 From: OLC Date: Fri, 21 Nov 2025 18:19:08 +0800 Subject: [PATCH 2/2] =?UTF-8?q?docs:=20=E6=9B=B4=E6=96=B0=201.8.6-fix1=20?= =?UTF-8?q?=E7=9A=84=20changelog?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- CHANGELOG.md | 7 +++++++ CHANGELOG_EN.md | 7 +++++++ 2 files changed, 14 insertions(+) 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