public override void OnInspectorGUI() { serializedObject.Update(); EditorGUILayout.Space(); EditorGUILayout.Space(); EditorGUILayout.HelpBox("Sequence Settings", MessageType.None); EditorGUILayout.PropertyField(updateOnFixedUpdate, new GUIContent("Fixed Update?")); EditorGUILayout.PropertyField(autoPlay, new GUIContent("Auto Play?")); EditorGUILayout.Space(); EditorGUILayout.Space(); EditorGUILayout.HelpBox("Utility", MessageType.None); var sequences = new List <USSequencer>(); foreach (var target in targets) { var sequence = target as USSequencer; if (sequence == null) { continue; } sequences.Add(sequence); } if (sequences.Count == 1 && GUILayout.Button("Open and Edit Sequence")) { USWindow.OpenuSequencerWindow(); Selection.activeObject = sequences[0]; } if (sequences.Count <= 1) { EditorGUILayout.Space(); EditorGUILayout.Space(); } if (GUILayout.Button(sequences.Count > 1 ? "Duplicate Sequences" : "Duplicate Sequence")) { foreach (var sequence in sequences) { USEditorUtility.DuplicateSequence(sequence); } } if (sequences.Count == 1 && GUILayout.Button(PrefabUtility.GetPrefabObject(sequences[0].gameObject) ? "Update Prefab" : "Create Prefab")) { USEditorUtility.CreatePrefabFrom(sequences[0], false); } serializedObject.ApplyModifiedProperties(); }
private void DisplayTopBar() { var space = 16.0f; GUILayout.Box("", EditorStyles.toolbar, GUILayout.ExpandWidth(true), GUILayout.Height(18.0f)); if (Event.current.type == EventType.Repaint) { TopBar = GUILayoutUtility.GetLastRect(); } using (new Shared.GUIBeginArea(TopBar)) { using (new Shared.GUIBeginHorizontal()) { if (GUILayout.Button("Create New Sequence", EditorStyles.toolbarButton)) { var newSequence = new GameObject("Sequence"); USUndoManager.RegisterCreatedObjectUndo(newSequence, "Create new sequence"); var sequence = newSequence.AddComponent <USSequencer>(); sequence.Version = USUpgradePaths.CurrentVersionNumber; USUndoManager.RegisterCreatedObjectUndo(sequence, "Create new sequence"); USUndoManager.RegisterCompleteObjectUndo(newSequence, "Create new sequence"); USRuntimeUtility.CreateAndAttachObserver(sequence); if (CurrentSequence == null) { Selection.activeGameObject = newSequence; Selection.activeTransform = newSequence.transform; SequenceSwitch(sequence); } Repaint(); } var currentSequence = CurrentSequence != null ? CurrentSequence.name : ""; var label = "Select a Sequence"; if (CurrentSequence != null) { label = String.Format("Editting : {0}", currentSequence); } if (GUILayout.Button(label, EditorStyles.toolbarButton, GUILayout.Width(150.0f))) { var menu = new GenericMenu(); var sequences = FindObjectsOfType(typeof(USSequencer)) as USSequencer[]; var orderedSequences = sequences.OrderBy(sequence => sequence.name); foreach (var sequence in orderedSequences) { menu.AddItem(new GUIContent(sequence.name), currentSequence == sequence.name ? true : false, (obj) => Selection.activeGameObject = (GameObject)obj, sequence.gameObject); } menu.ShowAsContext(); } GUILayout.Space(space); GUILayout.Box("", USEditorUtility.SeperatorStyle, GUILayout.Height(18.0f)); GUILayout.Space(space); if (CurrentSequence != null) { using (new Shared.GUIChangeColor((AnimationHelper.IsInAnimationMode || IsArmed) ? Color.red : GUI.color)) { if (GUILayout.Button(new GUIContent(!CurrentSequence.IsPlaying ? USEditorUtility.PlayButton : USEditorUtility.PauseButton, "Toggle Play Mode (P)"), USEditorUtility.ToolbarButtonSmall)) { PlayOrPause(); } if (GUILayout.Button(USEditorUtility.StopButton, USEditorUtility.ToolbarButtonSmall)) { Stop(); } } using (new Shared.GUIEnable(EditorApplication.isPlaying)) { var buttonContent = new GUIContent(USEditorUtility.RecordButton, !EditorApplication.isPlaying ? "You must be in Play Mode to enable this button" : "Start g"); if (GUILayout.Button(buttonContent, USEditorUtility.ToolbarButtonSmall)) { Record(); } } GUILayout.Space(space); USUndoManager.BeginChangeCheck(); GUILayout.Button(new GUIContent(USEditorUtility.PrevKeyframeButton, "Prev Keyframe (Alt + ,)"), USEditorUtility.ToolbarButtonSmall); if (USUndoManager.EndChangeCheck()) { USUndoManager.PropertyChange(this, "Previous Keyframe"); GoToPrevKeyframe(); } USUndoManager.BeginChangeCheck(); GUILayout.Button(new GUIContent(USEditorUtility.NextKeyframeButton, "Next Keyframe (Alt + .)"), USEditorUtility.ToolbarButtonSmall); if (USUndoManager.EndChangeCheck()) { USUndoManager.PropertyChange(this, "Next Keyframe"); GoToNextKeyframe(); } GUILayout.Space(space); GUILayout.Box("", USEditorUtility.SeperatorStyle, GUILayout.Height(18.0f)); GUILayout.Space(space); EditorGUILayout.LabelField(new GUIContent("Keyframe Snap", "The amount keyframes will snap to when dragged in the uSequencer window. (Left Shift to activate)"), GUILayout.MaxWidth(100.0f)); USUndoManager.BeginChangeCheck(); var snapAmount = EditorGUILayout.FloatField(new GUIContent("", "The amount keyframes will snap to when dragged in the uSequencer window. (Left Shift to activate)"), ContentRenderer.SnapAmount, GUILayout.MaxWidth(40.0f)); if (USUndoManager.EndChangeCheck()) { USUndoManager.PropertyChange(this, "Snap Amount"); ContentRenderer.SnapAmount = snapAmount; } GUILayout.Space(space); GUILayout.Box("", USEditorUtility.SeperatorStyle, GUILayout.Height(18.0f)); GUILayout.Space(space); } GUILayout.FlexibleSpace(); if (CurrentSequence && GUILayout.Button("Duplicate Sequence", EditorStyles.toolbarButton)) { USEditorUtility.DuplicateSequence(CurrentSequence); } if (CurrentSequence && GUILayout.Button(PrefabUtility.GetPrefabObject(CurrentSequence.gameObject) ? "Update Prefab" : "Create Prefab", EditorStyles.toolbarButton)) { CurrentSequence.Stop(); StopProcessingAnimationMode(); USEditorUtility.CreatePrefabFrom(CurrentSequence, false); } } } }