Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,13 @@

[English](CHANGELOG_EN.md) | 中文

## v1.8.6-fix1

- 修复 AnimatorParameterDriverManager 中的随机整数生成逻辑
- 修正 AnimatorParameterDriverManager 中随机整数生成的范围,确保包含最大值
- 修正复制参数操作的范围转换逻辑
- 更新 ModelParameterDriver 和 BlueprintID 组件的文档注释,增强可读性和理解性

## v1.8.6

- 新增 `ModelParameterDriver` 组件,支持在动画状态机中自定义参数控制
Expand Down
7 changes: 7 additions & 0 deletions CHANGELOG_EN.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,13 @@

namespace DuckovCustomModel.Core.MonoBehaviours.Animators
{
/// <summary>
/// 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.
/// </summary>
public class ModelParameterDriver : StateMachineBehaviour, ISerializationCallbackReceiver
{
public enum ChangeType
Expand Down Expand Up @@ -84,7 +91,18 @@ public class Parameter
public float destMin;
public float destMax;

/// <summary>
/// Runtime-only cached reference to the destination parameter.
/// Populated during initialization for performance optimization.
/// Not intended to be set manually or serialized.
/// </summary>
public object? DestParam;

/// <summary>
/// Runtime-only cached reference to the source parameter.
/// Populated during initialization for performance optimization.
/// Not intended to be set manually or serialized.
/// </summary>
public object? SourceParam;
}
}
Expand Down
4 changes: 4 additions & 0 deletions DuckovCustomModel.Core/MonoBehaviours/Packages/BlueprintID.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,14 @@

namespace DuckovCustomModel.Core.MonoBehaviours.Packages
{
/// <summary>
/// Assigns unique identifiers to game objects. Currently a placeholder for future functionality.
/// </summary>
[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")]
Expand Down
2 changes: 1 addition & 1 deletion DuckovCustomModel/Constant.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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";
}
}
Loading