private void OnEnable() { Selection.selectionChanged += SelectionChanged; SelectionChanged(); if (null == stateCollection) { stateCollection = UCCEManagerUtility.FindAnimStateColection(this); } }
/// <summary> /// Initialize the manager after deserialization. /// </summary> public override void Initialize(MainManagerWindow mainManagerWindow) { base.Initialize(mainManagerWindow); // Look for the ItemCollection within the scene if it isn't already populated. if (m_AnimationStateCollection == null) { m_AnimationStateCollection = UCCEManagerUtility.FindAnimStateColection(m_MainManagerWindow); } // The ItemCollection may have been serialized. if (m_AnimationStateCollection != null) { m_ItemIdTab.Initialize(m_AnimationStateCollection.ItemIds); m_ItemStateIndexTab.Initialize(m_AnimationStateCollection.ItemStateIndexes); m_AbilityIndexTab.Initialize(m_AnimationStateCollection.AbilityIndexes); } }
private void OnGUI() { if (m_AnimatorController == null) { GUILayout.Label("Please select an animator controller."); m_AnimatorController = (AnimatorController)EditorGUILayout.ObjectField(m_AnimatorController, typeof(AnimatorController)); if (null != m_AnimatorController) { Index(); } } else { // TODO: This will probably need to move out and shouldn't be done // every frame. Performing fine for now. scroll = GUILayout.BeginScrollView(scroll); { stateCollection = (AnimationStateCollection)EditorGUILayout.ObjectField(stateCollection, typeof(AnimationStateCollection)); if (currentSelection is AnimatorStateTransition) { DrawAnimatorTransition(currentSelection as AnimatorStateTransition, foldout: false); } else if (currentSelection is AnimatorStateMachine) { CombinedAnimatorState state = m_States.ContainsKey(currentSelection) ? m_States[currentSelection] : null; if (state.Parent == null) { DrawRootController(); } else { DrawAnimatorStateMachine(currentSelection as AnimatorStateMachine); } } else if (currentSelection is AnimatorState) { DrawAnimatorState(currentSelection as AnimatorState); } else { DrawRootController(); } } GUILayout.EndScrollView(); } }
/// <summary> /// Draws the ItemTypeManager. /// </summary> public override void OnGUI() { EditorGUILayout.BeginHorizontal(); var animStateCollection = EditorGUILayout.ObjectField("Animation State Collection", m_AnimationStateCollection, typeof(AnimationStateCollection), false) as AnimationStateCollection; if (GUILayout.Button("Create", GUILayout.MaxWidth(100))) { var path = EditorUtility.SaveFilePanel("Save Animation State Collection", "Assets", "AnimationStateCollection.asset", "asset"); if (path.Length != 0 && Application.dataPath.Length < path.Length) { animStateCollection = ScriptableObject.CreateInstance <AnimationStateCollection>(); // Save the collection. path = string.Format("Assets/{0}", path.Substring(Application.dataPath.Length + 1)); AssetDatabase.DeleteAsset(path); AssetDatabase.CreateAsset(animStateCollection, path); AssetDatabase.ImportAsset(path); } } EditorGUILayout.EndHorizontal(); if (animStateCollection != m_AnimationStateCollection) { m_AnimationStateCollection = animStateCollection; if (m_AnimationStateCollection != null) { EditorPrefs.SetString(UCCEManagerUtility.LastAnimationStateCollectionGUIDString, AssetDatabase.AssetPathToGUID(AssetDatabase.GetAssetPath(animStateCollection))); m_ItemIdTab.Initialize(m_AnimationStateCollection.ItemIds); m_ItemStateIndexTab.Initialize(m_AnimationStateCollection.ItemStateIndexes); m_AbilityIndexTab.Initialize(m_AnimationStateCollection.AbilityIndexes); } else { EditorPrefs.SetString(ManagerUtility.LastItemCollectionGUIDString, string.Empty); } } // ItemCollection must be populated in order to create Categories/ItemTypes. if (m_AnimationStateCollection == null) { EditorGUILayout.HelpBox("An AnimatioStateCollection must be selected. Use the \"Create\" button to create a new collection.", MessageType.Error); return; } if (m_ItemIdTab.animationStateSet == null) { m_ItemIdTab.Initialize(m_AnimationStateCollection.ItemIds); } if (m_ItemStateIndexTab.animationStateSet == null) { m_ItemStateIndexTab.Initialize(m_AnimationStateCollection.ItemStateIndexes); } if (m_AbilityIndexTab.animationStateSet == null) { m_AbilityIndexTab.Initialize(m_AnimationStateCollection.AbilityIndexes); } m_ToolbarSelection = GUILayout.Toolbar(m_ToolbarSelection, m_ToolbarStrings, EditorStyles.toolbarButton); DrawTab(m_Tabs[m_ToolbarSelection]); }