AnimatorParameter attribute #200
Luanrobs
started this conversation in
Show and tell
Replies: 1 comment 1 reply
-
|
Hi. Looks great! Small suggestions:
public Animator animator;
[AnimatorParameter(nameof(animator), AnimatorControllerParameterType.Float)]
public string myParameterName;If I understand correctly, EditorPrefs stores a mapping between the hash and the old name (when a parameter is deleted or renamed), and without this, the validator will only be able to show a meaningless hash. I don't think there's any other option, but it's preferable to store everything in one variable to avoid cluttering the storage. EditorPrefs.SetString("TriInspectorAnimatorParametersCache", JsonUtility.ToJson(cache)); |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
I’m currently working on a new attribute:
[AnimationParameter(animatorFieldName)]It’s designed for string or int fields, and it creates a dropdown dynamically filled with the parameter names from an Animator component referenced in another field.
What it does
It lets you pick parameters like "IsRunning" or "AttackTrigger" from a list instead of typing them manually, storing either the parameter name or its hash (via Animator.StringToHash) depending on the field type.
Example usage
If you rename or delete the parameter in the Animator, the inspector will automatically show an error.
Internally, I’m currently using EditorPrefs to store the parameter name and type.
This allows the system to keep track of parameters even when using hashes, so if a parameter is renamed or removed, the inspector can still detect the change and display a warning.
I’m not 100% sure this is the best approach yet, but it’s working surprisingly well so far, open to suggestions if anyone has a cleaner way to handle this!
Beta Was this translation helpful? Give feedback.
All reactions