File tree Expand file tree Collapse file tree 2 files changed +71
-0
lines changed
Expand file tree Collapse file tree 2 files changed +71
-0
lines changed Original file line number Diff line number Diff line change 1+ using UnityEngine ;
2+
3+ namespace Zigurous . Animation
4+ {
5+ /// <summary>
6+ /// An animation parameter that can be set on an animator. A hash id is
7+ /// automatically created for the parameter for optimal code.
8+ /// </summary>
9+ [ System . Serializable ]
10+ public struct AnimatorParameter
11+ {
12+ [ SerializeField ]
13+ [ HideInInspector ]
14+ private int _hash ;
15+
16+ /// <summary>
17+ /// The hash id of the animation parameter.
18+ /// </summary>
19+ public int hash => _hash ;
20+
21+ [ SerializeField ]
22+ [ Tooltip ( "The name of the animation parameter." ) ]
23+ private string _name ;
24+
25+ /// <summary>
26+ /// The name of the animation parameter.
27+ /// </summary>
28+ public string name
29+ {
30+ get => _name ;
31+ set
32+ {
33+ _name = value ;
34+ _hash = Animator . StringToHash ( value ) ;
35+ }
36+ }
37+
38+ /// <summary>
39+ /// Constructs a new animation parameter with the given name.
40+ /// </summary>
41+ public AnimatorParameter ( string name )
42+ {
43+ _name = name ;
44+ _hash = Animator . StringToHash ( name ) ;
45+ }
46+
47+ /// <summary>
48+ /// Generates a new hash for the parameter using the current name.
49+ /// </summary>
50+ public int GenerateHash ( )
51+ {
52+ _hash = Animator . StringToHash ( _name ) ;
53+ return _hash ;
54+ }
55+
56+ public static implicit operator AnimatorParameter ( string name ) => new AnimatorParameter ( name ) ;
57+
58+ }
59+
60+ }
You can’t perform that action at this time.
0 commit comments