override public void OnInspectorGUI() { serializedObject.Update(); SkeletonDataAsset asset = (SkeletonDataAsset)target; EditorGUI.BeginChangeCheck(); EditorGUILayout.PropertyField(atlasAsset); EditorGUILayout.PropertyField(skeletonJSON); EditorGUILayout.PropertyField(scale); if (EditorGUI.EndChangeCheck()) { if (m_previewUtility != null) { m_previewUtility.Cleanup(); m_previewUtility = null; } } SkeletonData skeletonData = asset.GetSkeletonData(asset.atlasAsset == null || asset.skeletonJSON == null); if (skeletonData != null) { showAnimationStateData = EditorGUILayout.Foldout(showAnimationStateData, "Animation State Data"); if (showAnimationStateData) { EditorGUILayout.PropertyField(defaultMix); // Animation names String[] animations = new String[skeletonData.Animations.Count]; for (int i = 0; i < animations.Length; i++) { animations[i] = skeletonData.Animations[i].Name; } for (int i = 0; i < fromAnimation.arraySize; i++) { SerializedProperty from = fromAnimation.GetArrayElementAtIndex(i); SerializedProperty to = toAnimation.GetArrayElementAtIndex(i); SerializedProperty durationProp = duration.GetArrayElementAtIndex(i); EditorGUILayout.BeginHorizontal(); from.stringValue = animations[EditorGUILayout.Popup(Math.Max(Array.IndexOf(animations, from.stringValue), 0), animations)]; to.stringValue = animations[EditorGUILayout.Popup(Math.Max(Array.IndexOf(animations, to.stringValue), 0), animations)]; durationProp.floatValue = EditorGUILayout.FloatField(durationProp.floatValue); if (GUILayout.Button("Delete")) { duration.DeleteArrayElementAtIndex(i); toAnimation.DeleteArrayElementAtIndex(i); fromAnimation.DeleteArrayElementAtIndex(i); } EditorGUILayout.EndHorizontal(); } EditorGUILayout.BeginHorizontal(); EditorGUILayout.Space(); if (GUILayout.Button("Add Mix")) { duration.arraySize++; toAnimation.arraySize++; fromAnimation.arraySize++; } EditorGUILayout.Space(); EditorGUILayout.EndHorizontal(); } if (GUILayout.Button(new GUIContent("Setup Pose", SpineEditorUtilities.Icons.skeleton), GUILayout.Width(105), GUILayout.Height(18))) { StopAnimation(); m_skeletonAnimation.skeleton.SetToSetupPose(); m_requireRefresh = true; } #if UNITY_4_3 m_showAnimationList = EditorGUILayout.Foldout(m_showAnimationList, new GUIContent("Animations", SpineEditorUtilities.Icons.animationRoot)); if (m_showAnimationList) { #else m_showAnimationList.target = EditorGUILayout.Foldout(m_showAnimationList.target, new GUIContent("Animations", SpineEditorUtilities.Icons.animationRoot)); if (EditorGUILayout.BeginFadeGroup(m_showAnimationList.faded)) { #endif EditorGUILayout.LabelField("Name", "Duration"); foreach (Spine.Animation a in skeletonData.Animations) { GUILayout.BeginHorizontal(); if (m_skeletonAnimation != null && m_skeletonAnimation.state != null) { if (m_skeletonAnimation.state.GetCurrent(0) != null && m_skeletonAnimation.state.GetCurrent(0).Animation == a) { GUI.contentColor = Color.black; if (GUILayout.Button("\u25BA", GUILayout.Width(24))) { StopAnimation(); } GUI.contentColor = Color.white; } else { if (GUILayout.Button("\u25BA", GUILayout.Width(24))) { PlayAnimation(a.Name, true); } } } else { GUILayout.Label("?", GUILayout.Width(24)); } EditorGUILayout.LabelField(new GUIContent(a.Name, SpineEditorUtilities.Icons.animation), new GUIContent(a.Duration.ToString("f3") + "s" + ("(" + (Mathf.RoundToInt(a.Duration * 30)) + ")").PadLeft(12, ' '))); GUILayout.EndHorizontal(); } } #if !UNITY_4_3 EditorGUILayout.EndFadeGroup(); #endif } if (!Application.isPlaying) { if (serializedObject.ApplyModifiedProperties() || (UnityEngine.Event.current.type == EventType.ValidateCommand && UnityEngine.Event.current.commandName == "UndoRedoPerformed") ) { asset.Reset(); } } }
override public void OnInspectorGUI() { serializedObject.Update(); SkeletonDataAsset asset = (SkeletonDataAsset)target; EditorGUILayout.PropertyField(atlasAsset); EditorGUILayout.PropertyField(skeletonJSON); EditorGUILayout.PropertyField(scale); SkeletonData skeletonData = asset.GetSkeletonData(asset.atlasAsset == null || asset.skeletonJSON == null); if (skeletonData != null) { showAnimationStateData = EditorGUILayout.Foldout(showAnimationStateData, "Animation State Data"); if (showAnimationStateData) { EditorGUILayout.PropertyField(defaultMix); // Animation names. String[] animations = new String[skeletonData.Animations.Count]; for (int i = 0; i < animations.Length; i++) { animations[i] = skeletonData.Animations[i].Name; } for (int i = 0; i < fromAnimation.arraySize; i++) { SerializedProperty from = fromAnimation.GetArrayElementAtIndex(i); SerializedProperty to = toAnimation.GetArrayElementAtIndex(i); SerializedProperty durationProp = duration.GetArrayElementAtIndex(i); EditorGUILayout.BeginHorizontal(); from.stringValue = animations[EditorGUILayout.Popup(Math.Max(Array.IndexOf(animations, from.stringValue), 0), animations)]; to.stringValue = animations[EditorGUILayout.Popup(Math.Max(Array.IndexOf(animations, to.stringValue), 0), animations)]; durationProp.floatValue = EditorGUILayout.FloatField(durationProp.floatValue); if (GUILayout.Button("Delete")) { duration.DeleteArrayElementAtIndex(i); toAnimation.DeleteArrayElementAtIndex(i); fromAnimation.DeleteArrayElementAtIndex(i); } EditorGUILayout.EndHorizontal(); } EditorGUILayout.BeginHorizontal(); EditorGUILayout.Space(); if (GUILayout.Button("Add Mix")) { duration.arraySize++; toAnimation.arraySize++; fromAnimation.arraySize++; } EditorGUILayout.Space(); EditorGUILayout.EndHorizontal(); } } if (!Application.isPlaying) { if (serializedObject.ApplyModifiedProperties() || (UnityEngine.Event.current.type == EventType.ValidateCommand && UnityEngine.Event.current.commandName == "UndoRedoPerformed") ) { asset.Reset(); } } }