dbrizov / NaughtyAttributes

Attribute Extensions for Unity
MIT License
4.47k stars 463 forks source link

[Request] AnimatorState Attribute #355

Open TiredOfEverything opened 1 year ago

TiredOfEverything commented 1 year ago

An attribute that fills a dropdown with all the names of the possible Animator states for an Animator.

TylerTemp commented 9 months ago

I've implement one on my own project. Though I did not make it a standalone one, but here you can change it as one you need:

  1. the struct itself, not need for modification: https://github.com/TylerTemp/SaintsField/blob/master/Runtime/AnimatorState.cs
  2. the attribute, delete the inherented interface and non-need properties: https://github.com/TylerTemp/SaintsField/blob/master/Runtime/AnimatorStateAttribute.cs
  3. the drawer: https://github.com/TylerTemp/SaintsField/blob/master/Editor/Drawers/AnimatorStateAttributeDrawer.cs

    1. change SaintsPropertyDrawer to PropertyDrawer
    2. change GetFieldHeight to override GetPropertyHeight and adjust parameters as needed.
    3. change DrawField to override OnGUI and adjust parameters
    4. delete all not-need functions, extra information helper, error handings, etc.

And should do the work