static public void OnInspectorPlayback(string name, CharacterCutScene character_animation, bool reset_playback) { if (!EditorUtility.IsPersistent(character_animation)) { EditorGUILayout.BeginHorizontal(); float playback_time = EditorGUILayout.FloatField(name + "Time", character_animation.PlaybackTime); playback_time = character_animation.PlaybackTime + (playback_time - character_animation.PlaybackTime) * 0.1f; bool update_playback_local = playback_time != character_animation.PlaybackTime; bool playback_back = playback_time < character_animation.PlaybackTime; if (update_playback_local) { if (character_animation.IsPlaying == false) { character_animation.Play(true); } else { character_animation.IsPause = true; } character_animation.UpdatePlay(playback_time); } float length = character_animation.CurrentState ? character_animation.CurrentState.length : 0f; EditorGUILayout.LabelField(string.Format("/ {0}", length)); EditorGUILayout.EndHorizontal(); character_animation.PlaybackSpeed = EditorGUILayout.Slider(name + "Speed", character_animation.PlaybackSpeed, 0f, 2f); if (character_animation.PlaybackSpeed < 0f) { character_animation.PlaybackSpeed = 0f; } } int cur_index = GetAnimIndex(character_animation.CurrentState); int new_index = EditorGUILayout.Popup("Current", cur_index, s_Animations); if (new_index != cur_index) { character_animation.Stop(); character_animation.CurrentState = character_animation.Animation[s_Animations[new_index]]; } else if (cur_index == 0) { character_animation.CurrentState = character_animation.Animation["default"]; } if (character_animation.IsPlaying == false) { character_animation.Play(false); } }
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(); }