public bool OnInspectorPlay(CharacterCutScene character_animation) { GUI.changed = false; // Color backup_color = GUI.color; bool reset_playback = false; if (!EditorUtility.IsPersistent(character_animation)) { EditorGUILayout.BeginHorizontal(); if (character_animation.IsPlaying == true) { if (character_animation.IsPause == false) { if (GUILayout.Button("Pause")) { character_animation.IsPause = true; } } else { if (GUILayout.Button("Resume")) { character_animation.IsPause = false; } } } else { if (GUILayout.Button("Play")) { character_animation.Play(false); } } if (GUILayout.Button("Reset")) { reset_playback = true; character_animation.Reset(); } if (GUILayout.Button("Stop")) { character_animation.Stop(); } EditorGUILayout.EndHorizontal(); } OnInspectorPlayback("Playback ", character_animation, reset_playback); if (GUI.changed == true) { EditorUtility.SetDirty((MonoBehaviour)character_animation); } if (EditorApplication.isPlaying == false && character_animation.IsPlaying) { EditorUtility.SetDirty((MonoBehaviour)character_animation); } return(true); }
static void OnSceneGUIInternal(CharacterCutScene character_animation) { if (character_animation.Animation == null || EditorApplication.isPlaying && UnityEditor.SceneManagement.EditorSceneManager.GetActiveScene().path.StartsWith("Assets/AniTest") == false) { return; } int width = 240, height = 20 + 20 * 4; Rect r = new Rect(Screen.width - width, Screen.height - height - 40, width, height); Vector2 mouse = Event.current.mousePosition; Rect r2 = r; r2.yMin -= 30; r2.xMin -= 10; r2.xMax += 10; r2.yMax += 10; if (r2.Contains(mouse) && Event.current.type == EventType.Layout) { int controlID = GUIUtility.GetControlID(1024, FocusType.Passive); HandleUtility.AddControl(controlID, 0F); } Handles.BeginGUI(); GUILayout.BeginArea(r, character_animation.gameObject.name, "Window"); bool reset_playback = false; EditorGUILayout.BeginHorizontal(); if (character_animation.IsPlaying == true) { if (character_animation.IsPause == false) { if (GUILayout.Button("Pause")) { character_animation.IsPause = true; } } else { if (GUILayout.Button("Resume")) { character_animation.IsPause = false; } } } else { if (GUILayout.Button("Play")) { character_animation.Play(false); } } if (GUILayout.Button("Reset")) { reset_playback = true; character_animation.Reset(); } if (GUILayout.Button("Stop")) { character_animation.Stop(); } EditorGUILayout.EndHorizontal(); EditorGUIUtility.labelWidth = 50f; OnInspectorPlayback("", character_animation, reset_playback); EditorGUIUtility.labelWidth = 0f; if (EditorApplication.isPlaying == false && character_animation.IsPlaying) { EditorUtility.SetDirty((MonoBehaviour)character_animation); } GUILayout.EndArea(); Handles.EndGUI(); }