public void Dispose() { var destroy = EditorApplication.isPlaying ? (System.Action <Object>)Object.Destroy : (System.Action <Object>)Object.DestroyImmediate; if (recorder) { recorder.ResetRecording(); destroy(recorder); } if ((proxies?.Length ?? 0) != 0 && proxies[0]) { destroy(proxies[0].parent.gameObject); } animator = null; recorder = null; proxies = null; }
public AnimRecorder(Animator animator) { this.animator = animator; this.recorder = new GameObjectRecorder(animator.gameObject); this.proxies = new Transform[HumanTrait.BoneCount]; var hideFlags = HideFlags.DontSaveInEditor; // | HideFlags.HideInHierarchy var proxyRoot = EditorUtility.CreateGameObjectWithHideFlags("_bones_", hideFlags).transform; proxyRoot.SetParent(animator.transform, false); for (int i = 0; i < HumanTrait.BoneCount; i++) { proxies[i] = EditorUtility.CreateGameObjectWithHideFlags(HumanTrait.BoneName[i], hideFlags).transform; proxies[i].SetParent(proxyRoot, false); } bindProxies(); }