private void FloatingOnGUI() { GUILayout.Box("", FloatingBackground, GUILayout.MaxWidth(FloatingWidth), GUILayout.Height(17.0f)); if (Event.current.type == EventType.Repaint) { FloatingBackgroundRect = GUILayoutUtility.GetLastRect(); } bool wasLabelPressed; var newExpandedState = USEditor.FoldoutLabel(FloatingBackgroundRect, IsExpanded, USEditorUtility.GetReadableTimelineContainerName(TimelineContainer), out wasLabelPressed); if (newExpandedState != IsExpanded) { USUndoManager.PropertyChange(this, "Foldout"); IsExpanded = newExpandedState; } base.FloatingOnGUI(0); if (!USRuntimeUtility.HasObserverTimeline(TimelineContainer.transform) && TimelineContainer.AffectedObject == null) { IsExpanded = false; } }
static bool RunUpgradePath1_11To1_15(USSequencer sequence) { sequence.Version = 5; USRuntimeUtility.CreateAndAttachObserver(sequence); return(true); }
private void RunningTimeUpdated(USSequencer sequence) { Button component = base.GetComponent <Button>(); bool flag = USRuntimeUtility.CanPlaySequence(sequence); component.interactable = flag; Debug.Log(flag); }
private void RunningTimeUpdated(USSequencer sequence) { var button = GetComponent <Button>(); var canPlay = USRuntimeUtility.CanPlaySequence(sequence); button.interactable = canPlay; Debug.Log(canPlay); }
public override void FireEvent() { if (!Application.isPlaying) { Debug.Log("Recording events only work when in play mode"); return; } USRuntimeUtility.StopRecordingSequence(); }
public static void StopRecordingSequence() { USRecordSequence orSpawnRecorder = USRuntimeUtility.GetOrSpawnRecorder(); if (orSpawnRecorder) { UnityEngine.Object.DestroyImmediate(orSpawnRecorder.gameObject); } }
public override void FireEvent() { if (!Application.isPlaying) { Debug.Log("Recording events only work when in play mode"); return; } USRuntimeUtility.StartRecordingSequence(base.Sequence, USRecordRuntimePreferences.CapturePath, USRecord.GetFramerate(), USRecord.GetUpscaleAmount()); }
public static void StartRecordingSequence(USSequencer sequence, string capturePath, int captureFramerate, int upScaleAmount) { USRecordSequence orSpawnRecorder = USRuntimeUtility.GetOrSpawnRecorder(); orSpawnRecorder.StartRecording(); orSpawnRecorder.RecordOnStart = true; orSpawnRecorder.CapturePath = capturePath; orSpawnRecorder.CaptureFrameRate = captureFramerate; orSpawnRecorder.UpscaleAmount = upScaleAmount; }
private void Start() { Button button = base.GetComponent <Button>(); if (!button) { Debug.LogError("The component Play Sequence button must be added to a Unity UI Button"); return; } if (!this.sequenceToPlay) { Debug.LogError("The Sequence to play field must be hooked up in the Inspector"); return; } button.onClick.AddListener(delegate { this.PlaySequence(); }); button.interactable = !this.sequenceToPlay.IsPlaying; if (this.manageInteractiveState) { USSequencer expr_95 = this.sequenceToPlay; expr_95.OnRunningTimeSet = (USSequencer.PlaybackDelegate) Delegate.Combine(expr_95.OnRunningTimeSet, new USSequencer.PlaybackDelegate(delegate(USSequencer sequence) { button.interactable = USRuntimeUtility.CanPlaySequence(sequence); })); USSequencer expr_BC = this.sequenceToPlay; expr_BC.PlaybackStarted = (USSequencer.PlaybackDelegate) Delegate.Combine(expr_BC.PlaybackStarted, new USSequencer.PlaybackDelegate(delegate(USSequencer sequence) { button.interactable = false; })); USSequencer expr_E3 = this.sequenceToPlay; expr_E3.PlaybackPaused = (USSequencer.PlaybackDelegate) Delegate.Combine(expr_E3.PlaybackPaused, new USSequencer.PlaybackDelegate(delegate(USSequencer sequence) { button.interactable = true; })); USSequencer expr_10A = this.sequenceToPlay; expr_10A.PlaybackFinished = (USSequencer.PlaybackDelegate) Delegate.Combine(expr_10A.PlaybackFinished, new USSequencer.PlaybackDelegate(delegate(USSequencer sequence) { button.interactable = false; })); USSequencer expr_131 = this.sequenceToPlay; expr_131.PlaybackStopped = (USSequencer.PlaybackDelegate) Delegate.Combine(expr_131.PlaybackStopped, new USSequencer.PlaybackDelegate(delegate(USSequencer sequence) { button.interactable = true; })); } }
public USPropertyInfo GetProperty(string propertyName, Component component) { foreach (USPropertyInfo current in this.propertyList) { if (!(current == null)) { string componentType = current.ComponentType; string b = USRuntimeUtility.ConvertToSerializableName(component.GetType().ToString()); if (componentType == b && (current.propertyName == propertyName || current.fieldName == propertyName)) { return(current); } } } return(null); }
public static bool HasPropertyTimeline(Transform transform) { if (!USRuntimeUtility.IsTimelineContainer(transform)) { return(false); } Transform[] componentsInChildren = transform.GetComponentsInChildren <Transform>(); for (int i = 0; i < componentsInChildren.Length; i++) { Transform transform2 = componentsInChildren[i]; if (USRuntimeUtility.IsPropertyTimeline(transform2)) { return(true); } } return(false); }
private void ContentPaneOnGUI() { GUILayout.Box("", TimelineBackground, GUILayout.Height(17.0f), GUILayout.ExpandWidth(true)); using (new Shared.GUIBeginArea(ContentBackgroundRect)) { if (!USRuntimeUtility.HasObserverTimeline(TimelineContainer.transform) && TimelineContainer.AffectedObject == null) { GUILayout.Label(string.Format("The Affected Object {0} is not in your scene.", TimelineContainer.AffectedObjectPath)); } } if (Event.current.type == EventType.Repaint) { ContentBackgroundRect = GUILayoutUtility.GetLastRect(); } }
private void OnItemClicked(IUSHierarchyItem item) { var timelineContainerItem = item as USTimelineContainerHierarchyItem; if (timelineContainerItem != null && !USRuntimeUtility.HasObserverTimeline(timelineContainerItem.TimelineContainer.transform)) { EditorGUIUtility.PingObject(timelineContainerItem.TimelineContainer.AffectedObject); Selection.activeGameObject = timelineContainerItem.TimelineContainer.AffectedObject.gameObject; Selection.activeTransform = timelineContainerItem.TimelineContainer.AffectedObject; } var timelineHierarchyItem = item as IUSTimelineHierarchyItem; if (timelineHierarchyItem) { EditorGUIUtility.PingObject(timelineHierarchyItem.PingableObject); Selection.activeTransform = timelineHierarchyItem.PingableObject; } }
public static bool IsObserverContainer(Transform transform) { USTimelineContainer component = transform.GetComponent <USTimelineContainer>(); if (component == null) { return(false); } USTimelineBase[] timelines = component.Timelines; for (int i = 0; i < timelines.Length; i++) { USTimelineBase uSTimelineBase = timelines[i]; if (USRuntimeUtility.IsObserverTimeline(uSTimelineBase.transform)) { return(true); } } return(false); }
public USPropertyInfo GetProperty(string propertyName, Component component) { foreach (var property in propertyList) { if (property == null) { continue; } var propertyComponentType = USRuntimeUtility.ConvertToSerializableName(property.ComponentType); var componentType = USRuntimeUtility.ConvertToSerializableName(component.GetType().ToString()); if (propertyComponentType == componentType && (property.propertyName == propertyName || property.fieldName == propertyName)) { return(property); } } return(null); }
private void ProcessDuplicateToSequence(IUSHierarchyItem item, USSequencer sequence) { var affectedObject = default(Transform); var timelineContainer = item as USTimelineContainerHierarchyItem; var timeline = item as IUSTimelineHierarchyItem; if (timelineContainer != null) { affectedObject = timelineContainer.TimelineContainer.AffectedObject; } if (timeline != null) { affectedObject = timeline.BaseTimeline.AffectedObject; } if (timelineContainer && USRuntimeUtility.HasTimelineContainerWithAffectedObject(sequence, affectedObject)) { EditorUtility.DisplayDialog("Cannot continue", string.Format("The sequence {0} already has timelines for the object {1}", sequence.name, affectedObject.name), "Ok"); return; } if (timelineContainer) { var newTimelineContainer = USEditor.DuplicateTimelineContainer(timelineContainer.TimelineContainer, sequence); USUndoManager.RegisterCreatedObjectUndo(newTimelineContainer.gameObject, "Duplicate Timeline"); } if (timeline) { var newTimelineContainer = sequence.GetTimelineContainerFor(timeline.BaseTimeline.AffectedObject); if (newTimelineContainer == null) { newTimelineContainer = sequence.CreateNewTimelineContainer(timeline.BaseTimeline.AffectedObject); USUndoManager.RegisterCreatedObjectUndo(newTimelineContainer.gameObject, "Duplicate Timeline"); } var newTimeline = USEditor.DuplicateTimeline(timeline.BaseTimeline, newTimelineContainer); USUndoManager.RegisterCreatedObjectUndo(newTimeline.gameObject, "Duplicate Timeline"); } }
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); } } } }
private void Start() { var button = GetComponent <Button>(); if (!button) { Debug.LogError("The component Play Sequence button must be added to a Unity UI Button"); return; } if (!sequenceToPlay) { Debug.LogError("The Sequence to play field must be hooked up in the Inspector"); return; } button.onClick.AddListener(() => PlaySequence()); button.interactable = !sequenceToPlay.IsPlaying; if (manageInteractiveState) { sequenceToPlay.OnRunningTimeSet += (sequence) => button.interactable = USRuntimeUtility.CanPlaySequence(sequence); sequenceToPlay.PlaybackStarted += (sequence) => button.interactable = false; sequenceToPlay.PlaybackPaused += (sequence) => button.interactable = true; sequenceToPlay.PlaybackFinished += (sequence) => button.interactable = true; sequenceToPlay.PlaybackStopped += (sequence) => button.interactable = true; } }
public static bool CanContextClickTimelineContainer(USTimelineContainer timelineContainer) { return(!USRuntimeUtility.HasObserverTimeline(timelineContainer.transform)); }
private void OnItemContextClicked(IUSHierarchyItem item) { var timelineContainerItem = item as USTimelineContainerHierarchyItem; var timelineHierarchyItem = item as IUSTimelineHierarchyItem; var contextMenu = new GenericMenu(); var canContextClickTimelineContainer = !timelineContainerItem || USEditorUtility.CanContextClickTimelineContainer(timelineContainerItem.TimelineContainer); if (!canContextClickTimelineContainer) { return; } var canContextClickTimeline = !timelineHierarchyItem || USEditorUtility.CanContextClickTimeline(timelineHierarchyItem.BaseTimeline); if (!canContextClickTimeline) { return; } if (timelineHierarchyItem || timelineContainerItem) { contextMenu.AddItem(new GUIContent("Remove"), false, () => ProcessDelete(item)); } // if we context click on a hierarchy container, always allow the duplication var isDuplicateEnabled = timelineContainerItem != null ? true :false; // If we context click on a hierarchy item, we need to make sure we can duplicate that item. if (timelineHierarchyItem) { var customAttribute = timelineHierarchyItem.GetType().GetCustomAttributes(typeof(USCustomTimelineHierarchyItem), true).FirstOrDefault() as USCustomTimelineHierarchyItem; if (customAttribute != default(USCustomTimelineHierarchyItem)) { if (customAttribute.CanBeManuallyAddToSequence && customAttribute.MaxNumberPerSequence > 1) { isDuplicateEnabled = true; } } else { isDuplicateEnabled = true; } } if (isDuplicateEnabled) { contextMenu.AddSeparator("Copy To/This Sequence"); contextMenu.AddItem(new GUIContent("Copy To/Duplicate"), false, () => ProcessDuplicate(item)); contextMenu.AddSeparator("Copy To/Other Sequences"); } else { contextMenu.AddDisabledItem(new GUIContent("Copy To/This Sequence")); } var sequences = FindObjectsOfType(typeof(USSequencer)) as USSequencer[]; var orderedSequences = sequences.OrderBy(sequence => sequence.name).Where(sequence => sequence != CurrentSequence); foreach (var sequence in orderedSequences) { contextMenu.AddItem(new GUIContent(string.Format("{0}/{1}", "Copy To", sequence.name)), false, (obj) => ProcessDuplicateToSequence(item, (USSequencer)obj), sequence); } if (timelineContainerItem) { var customKeyValuePairs = USEditorUtility.CustomTimelineAttributes; foreach (var customKeyValuePair in customKeyValuePairs) { var customTimelineDescription = customKeyValuePair.Key; if (!customTimelineDescription.CanBeManuallyAddToSequence) { continue; } if (USRuntimeUtility.GetNumberOfTimelinesOfType(customTimelineDescription.InspectedType, timelineContainerItem.TimelineContainer) >= customTimelineDescription.MaxNumberPerSequence) { continue; } contextMenu.AddItem( new GUIContent(string.Format("Add Timeline/{0}", customTimelineDescription.FriendlyName)), false, (obj) => { AddNewTimeline((obj as object[])[0] as USTimelineContainerHierarchyItem, (obj as object[])[1] as USCustomTimelineHierarchyItem); }, new object[] { timelineContainerItem, customTimelineDescription } ); } } item.AddContextItems(contextMenu); if (timelineContainerItem != null && (timelineContainerItem.TimelineContainer.AffectedObject == null || (Selection.activeGameObject != null && Selection.activeObject != timelineContainerItem.TimelineContainer.AffectedObject.gameObject))) { if (Selection.activeGameObject != null) { contextMenu.AddItem( new GUIContent(string.Format("Update Affected Object : {0}", Selection.activeGameObject.name)), false, () => UpdateAffectedObject(timelineContainerItem, Selection.activeGameObject)); } } contextMenu.ShowAsContext(); }