public CGFAnimationHierarchyEditorTool() { _currentSelectionGameObject = new TypeGameObject(); _currentSelectionGameObject = TypeGameObject.None; _animationClips = new List <AnimationClip>(); _myanimationClips = new List <AnimationClip>(); _tempPathOverrides = new Dictionary <string, string>(); _tempPathRemoveds = new Dictionary <string, string>(); _gameObjects = new List <GameObject>(); _changeAll = false; }
private void OnSelectionChange() { _animationClips.Clear(); _myanimationClips.Clear(); clipNames.Clear(); _animatorObject = null; _myruntime = null; _animatorObject2 = null; index = 0; if (Selection.activeObject is AnimationClip) { _currentSelectionGameObject = TypeGameObject.AnimationClip; } else if (Selection.activeGameObject is GameObject) { _currentSelectionGameObject = TypeGameObject.GameObject; } else if (Selection.activeObject is RuntimeAnimatorController) { _currentSelectionGameObject = TypeGameObject.RuntimeAnimatorController; } else { _currentSelectionGameObject = TypeGameObject.None; } switch (_currentSelectionGameObject) { case TypeGameObject.AnimationClip: _animationClips.Add((AnimationClip)Selection.activeObject); FillModel(); break; case TypeGameObject.GameObject: if (Selection.activeGameObject.GetComponent <Animator>() == null) { _currentSelectionGameObject = TypeGameObject.None; } else if (Selection.activeGameObject.GetComponent <Animator>() != null) { _animatorObject2 = Selection.activeGameObject.GetComponent <Animator>(); _animatorObject = _animatorObject2; if (_animatorObject2.runtimeAnimatorController != null) { _myruntime = _animatorObject2.runtimeAnimatorController; if (_myruntime.animationClips.Length > 0) { foreach (AnimationClip i in _myruntime.animationClips) { _myanimationClips.Add(i); } foreach (AnimationClip e in _myanimationClips) { clipNames.Add(e.name); } foreach (AnimationClip o in _myanimationClips) { _animationClips.Add(o); } FillModel(); } else { _currentSelectionGameObject = TypeGameObject.None; } } else { _currentSelectionGameObject = TypeGameObject.None; } } break; case TypeGameObject.RuntimeAnimatorController: foreach (RuntimeAnimatorController o in Selection.objects) { _myruntime = o; } foreach (AnimationClip i in _myruntime.animationClips) { _myanimationClips.Add(i); } foreach (AnimationClip e in _myanimationClips) { clipNames.Add(e.name); } foreach (AnimationClip o in _myanimationClips) { _animationClips.Add(o); } FillModel(); break; } this.Repaint(); }