@@ -73,20 +73,37 @@ public Transform TransferAnimationDest
73
73
}
74
74
}
75
75
76
+ /// <summary>
77
+ /// Get the Unity object (in this case transform), associated with the given binding ID.
78
+ /// </summary>
79
+ /// <param name="id">Binding ID</param>
80
+ /// <returns>Transform associated with binding ID</returns>
76
81
static Transform GetBinding ( string id )
77
82
{
78
83
// return BindingManager.Get(m_BindingId) as GameObject;
79
84
var method = Type . GetType ( "UnityEditor.Recorder.BindingManager,Unity.Recorder.Editor" ) . GetMethod ( "Get" , System . Reflection . BindingFlags . Static | System . Reflection . BindingFlags . Public ) ;
80
85
return method . Invoke ( null , new object [ ] { id } ) as Transform ;
81
86
}
82
87
88
+ /// <summary>
89
+ /// Set the binding ID to be associated with the given Unity object.
90
+ /// This information will be saved on domain reload, so that the object can still be found
91
+ /// with the binding ID.
92
+ /// </summary>
93
+ /// <param name="id">Binding ID</param>
94
+ /// <param name="obj">Unity Object</param>
83
95
static void SetBinding ( string id , UnityEngine . Object obj )
84
96
{
85
97
// BindingManager.Set(m_BindingId, value);
86
98
var method = Type . GetType ( "UnityEditor.Recorder.BindingManager,Unity.Recorder.Editor" ) . GetMethod ( "Set" , System . Reflection . BindingFlags . Static | System . Reflection . BindingFlags . Public ) ;
87
99
method . Invoke ( null , new object [ ] { id , obj } ) ;
88
100
}
89
101
102
+ /// <summary>
103
+ /// Get a binding ID for the transform, so that the reference survives domain reload. Maintaining a direct reference would not work
104
+ /// as all scene objects are destroyed and recreated on reload (e.g. when entering/exiting playmode).
105
+ /// </summary>
106
+ /// <returns>Binding ID</returns>
90
107
static string GenerateBindingId ( )
91
108
{
92
109
return GUID . Generate ( ) . ToString ( ) ;
0 commit comments