Esempio n. 1
0
        private void SequenceUpdate()
        {
            if (CurrentSequence)
            {
                float currentTime = Time.realtimeSinceStartup;
                float deltaTime   = currentTime - PreviousTime;
                if (Mathf.Abs(deltaTime) > JSequencer.SequenceUpdateRate)
                {
                    if (CurrentSequence.IsPlaying && !Application.isPlaying)
                    {
                        //CurrentSequence.UpdateSequencer(deltaTime * Time.timeScale);
                        Repaint();
                    }
                    PreviousTime = currentTime;
                }
            }
            JSequencer nextSequence = null;

            if (Selection.activeGameObject != null && (CurrentSequence == null || Selection.activeGameObject != CurrentSequence.gameObject))
            {
                nextSequence = Selection.activeGameObject.GetComponent <JSequencer>();
                if (nextSequence != null)
                {
                    bool isPrefab = PrefabUtility.GetPrefabParent(nextSequence.gameObject) == null && PrefabUtility.GetPrefabObject(nextSequence.gameObject) != null;
                    if (isPrefab)
                    {
                        nextSequence = null;
                    }
                }
            }
            else
            {
                return;
            }

            if (nextSequence == null)
            {
                return;
            }

            if (!Application.isPlaying && CurrentSequence != nextSequence)
            {
                if (CurrentSequence)
                {
                    CurrentSequence.Stop();
                }

                if (nextSequence)
                {
                    nextSequence.Stop();
                }

                StopProcessingAnimationMode();
            }

            SequenceSwitch(nextSequence);

            Repaint();
        }
Esempio n. 2
0
 private void Stop()
 {
     if (!CurrentSequence)
     {
         return;
     }
     CurrentSequence.Stop();
     StopProcessingAnimationMode();
 }
Esempio n. 3
0
 public void SetRunningTime(float newRunningTime)
 {
     StartProcessingAnimationMode();
     if (!CurrentSequence.IsPlaying)
     {
         CurrentSequence.Play();
     }
     CurrentSequence.Pause();
     CurrentSequence.RunningTime = newRunningTime;
 }
Esempio n. 4
0
        public IEnumerable <IRenderable> Render(WPos pos, WVec offset, int zOffset, PaletteReference palette, float scale)
        {
            if (CurrentSequence.ShadowStart >= 0)
            {
                var shadow = CurrentSequence.GetShadow(CurrentFrame, facingFunc());
                yield return(new SpriteRenderable(shadow, pos, offset, CurrentSequence.ShadowZOffset + zOffset, palette, scale, true));
            }

            yield return(new SpriteRenderable(Image, pos, offset, CurrentSequence.ZOffset + zOffset, palette, scale, IsDecoration));
        }
Esempio n. 5
0
        private void OnGUI()
        {
            if (!CurrentSequence)
            {
                ShowNotification(new GUIContent("Select a Sequence Or Create New One"));
            }
            if (CurrentSequence && CurrentSequence.TimelineContainerCount < 1)
            {
                ShowNotification(new GUIContent("Drag A Object To Sequence Or add a New Container"));
            }

            if (CurrentSequence && CurrentSequence.TimelineContainerCount >= 1 && EditorApplication.timeSinceStartup - showAnimationModeTime > 3000)
            {
                RemoveNotification();
            }

            GUILayout.BeginVertical();
            {
                DisplayTopBar();
                DisplayBottomBar();
                DisplayEdittableArea();
            }
            GUILayout.EndVertical();


            ProcessHotkeys();

            if (UnityEngine.Event.current.type == EventType.DragUpdated)
            {
                DragAndDrop.visualMode = DragAndDropVisualMode.Link;
                UnityEngine.Event.current.Use();
            }

            if (UnityEngine.Event.current.type == EventType.DragPerform)
            {
                foreach (UnityEngine.Object dragObject in DragAndDrop.objectReferences)
                {
                    GameObject GO = dragObject as GameObject;
                    if (CurrentSequence)
                    {
                        if (GO != CurrentSequence.gameObject)
                        {
                            DragAndDrop.AcceptDrag();
                            List <JTimelineBase> list = CurrentSequence.CreateContainers(GO.transform);
                            foreach (var line in list)
                            {
                                ContentRenderer.AddNewTimeLineForRender(line);
                            }
                        }
                    }
                }
                UnityEngine.Event.current.Use();
            }
        }
Esempio n. 6
0
 private void OnHierarchyChanged()
 {
     if (Application.isPlaying)
     {
         return;
     }
     if (CurrentSequence)
     {
         CurrentSequence.ResetCachedData();
     }
 }
Esempio n. 7
0
        public void SetRunningTime(float newRunningTime)
        {
            StartProcessingAnimationMode();
            if (!CurrentSequence.IsPlaying)
            {
                CurrentSequence.Play();
            }
            CurrentSequence.Pause();

            USUndoManager.PropertyChange(CurrentSequence, "Set Running Time");
            CurrentSequence.RunningTime = newRunningTime;
        }
Esempio n. 8
0
        public IRenderable[] Render(WPos pos, WVec offset, int zOffset, PaletteReference palette, float scale)
        {
            var imageRenderable = new SpriteRenderable(Image, pos, offset, CurrentSequence.ZOffset + zOffset, palette, scale, IsDecoration);

            if (CurrentSequence.ShadowStart >= 0)
            {
                var shadow           = CurrentSequence.GetShadow(CurrentFrame, facingFunc());
                var shadowRenderable = new SpriteRenderable(shadow, pos, offset, CurrentSequence.ShadowZOffset + zOffset, palette, scale, true);
                return(new IRenderable[] { shadowRenderable, imageRenderable });
            }

            return(new IRenderable[] { imageRenderable });
        }
Esempio n. 9
0
        public IRenderable[] Render(WPos pos, WVec offset, int zOffset, PaletteReference palette)
        {
            var tintModifiers   = CurrentSequence.IgnoreWorldTint ? TintModifiers.IgnoreWorldTint : TintModifiers.None;
            var imageRenderable = new SpriteRenderable(Image, pos, offset, CurrentSequence.ZOffset + zOffset, palette, CurrentSequence.Scale, IsDecoration, tintModifiers);

            if (CurrentSequence.ShadowStart >= 0)
            {
                var shadow           = CurrentSequence.GetShadow(CurrentFrame, facingFunc());
                var shadowRenderable = new SpriteRenderable(shadow, pos, offset, CurrentSequence.ShadowZOffset + zOffset, palette, CurrentSequence.Scale, true, tintModifiers);
                return(new IRenderable[] { shadowRenderable, imageRenderable });
            }

            return(new IRenderable[] { imageRenderable });
        }
Esempio n. 10
0
        private void StopProcessingAnimationMode()
        {
            if (CurrentSequence)
            {
                CurrentSequence.Stop();
            }

            if (Application.isPlaying)
            {
                return;
            }

            ContentRenderer.RestoreBaseState();
        }
Esempio n. 11
0
        public IRenderable[] RenderUI(int2 pos, WVec offset, int zOffset, PaletteReference palette, float scale)
        {
            var imagePos        = pos - new int2((int)(scale * Image.Size.X / 2), (int)(scale * Image.Size.Y / 2));
            var imageRenderable = new UISpriteRenderable(Image, WPos.Zero + offset, imagePos, CurrentSequence.ZOffset + zOffset, palette, scale);

            if (CurrentSequence.ShadowStart >= 0)
            {
                var shadow           = CurrentSequence.GetShadow(CurrentFrame, facingFunc());
                var shadowPos        = pos - new int2((int)(scale * shadow.Size.X / 2), (int)(scale * shadow.Size.Y / 2));
                var shadowRenderable = new UISpriteRenderable(shadow, WPos.Zero + offset, shadowPos, CurrentSequence.ShadowZOffset + zOffset, palette, scale);
                return(new IRenderable[] { shadowRenderable, imageRenderable });
            }

            return(new IRenderable[] { imageRenderable });
        }
Esempio n. 12
0
        private void OnHierarchyChanged()
        {
            if (Application.isPlaying)
            {
                return;
            }

#if WELLFIRED_INTERNAL
            Debug.Log("Hierarchy Changed");
#endif

            if (CurrentSequence)
            {
                CurrentSequence.ResetCachedData();
            }
        }
Esempio n. 13
0
        private void OnDestroy()
        {
            thisWindow = null;
            EditorApplication.hierarchyWindowChanged -= OnHierarchyChanged;
            SceneView.onSceneGUIDelegate             -= OnScene;
            Undo.undoRedoPerformed -= UndoRedoCallback;
            EditorApplication.playmodeStateChanged -= PlayModeStateChanged;
            EditorApplication.update -= SequenceUpdate;

            StopProcessingAnimationMode();

            if (CurrentSequence)
            {
                CurrentSequence.Stop();
            }
        }
Esempio n. 14
0
        public IRenderable[] RenderUI(WorldRenderer wr, int2 pos, WVec offset, int zOffset, PaletteReference palette, float scale = 1f)
        {
            scale *= CurrentSequence.Scale;
            var screenOffset    = (scale * wr.ScreenVectorComponents(offset)).XY.ToInt2();
            var imagePos        = pos + screenOffset - new int2((int)(scale * Image.Size.X / 2), (int)(scale * Image.Size.Y / 2));
            var imageRenderable = new UISpriteRenderable(Image, WPos.Zero + offset, imagePos, CurrentSequence.ZOffset + zOffset, palette, scale);

            if (CurrentSequence.ShadowStart >= 0)
            {
                var shadow           = CurrentSequence.GetShadow(CurrentFrame, facingFunc());
                var shadowPos        = pos - new int2((int)(scale * shadow.Size.X / 2), (int)(scale * shadow.Size.Y / 2));
                var shadowRenderable = new UISpriteRenderable(shadow, WPos.Zero + offset, shadowPos, CurrentSequence.ShadowZOffset + zOffset, palette, scale);
                return(new IRenderable[] { shadowRenderable, imageRenderable });
            }

            return(new IRenderable[] { imageRenderable });
        }
Esempio n. 15
0
        private void PlayOrPause()
        {
            if (!CurrentSequence)
            {
                return;
            }

            if (CurrentSequence.IsPlaying)
            {
                CurrentSequence.Pause();
            }
            else
            {
                StartProcessingAnimationMode();
                CurrentSequence.Play();
            }
        }
Esempio n. 16
0
        private void PlayOrPause()
        {
            if (!CurrentSequence)
            {
                return;
            }

            if (CurrentSequence.IsPlaying)
            {
                CurrentSequence.Pause();

                if (isArmed && GetOrSpawnRecorder())
                {
                    GetOrSpawnRecorder().PauseRecording();
                }
            }
            else
            {
                USUndoManager.PropertyChange(CurrentSequence, "Play");

                if (isArmed && !System.IO.Directory.Exists(USRecordRuntimePreferences.CapturePath))
                {
                    EditorUtility.DisplayDialog("Error", String.Format("Recording Directory : {0} doesn't exist, make sure you set one up in the uSequencer preferences (Edit/uSeqeucer/Recording Preferences)", USRecordRuntimePreferences.CapturePath), "OK");
                    return;
                }

                StartProcessingAnimationMode();
                CurrentSequence.Play();

                if (isArmed && GetOrSpawnRecorder())
                {
                    var recordingSequence = GetOrSpawnRecorder();

                    recordingSequence.StartRecording();

                    recordingSequence.CapturePath      = USRecordRuntimePreferences.CapturePath;
                    recordingSequence.CaptureFrameRate = USRecord.GetFramerate();
                    recordingSequence.UpscaleAmount    = USRecord.GetUpscaleAmount();
                }
            }
        }
Esempio n. 17
0
        private void StopProcessingAnimationMode()
        {
            if (CurrentSequence)
            {
                CurrentSequence.Stop();
            }

            if (!AnimationHelper.IsInAnimationMode)
            {
                return;
            }

            if (Application.isPlaying)
            {
                return;
            }

            USUndoManager.RegisterCompleteObjectUndo(this, "Play");
            IsInAnimationMode = false;

            ContentRenderer.RestoreBaseState();
        }
Esempio n. 18
0
        private void Stop()
        {
            if (!CurrentSequence)
            {
                return;
            }

            USUndoManager.PropertyChange(CurrentSequence, "Stop");

            CurrentSequence.Stop();
            StopProcessingAnimationMode();

            if (isArmed)
            {
                if (GetOrSpawnRecorder())
                {
                    GetOrSpawnRecorder().StopRecording();
                }

                DestroyImmediate(GetOrSpawnRecorder().gameObject);
            }

            isArmed = false;
        }
Esempio n. 19
0
        private void ProcessTaskLoop()
        {
            lock (_lockObj)
            {
                if (IsRunning)
                {
                    return;
                }

                IsRunning = true;
            }

            try
            {
                while (TakeSequence())
                {
                    InnerProcessTask(CurrentSequence);
                    CurrentSequence.Dispose();
                    CurrentSequence = null;
                }
            }
            catch (Exception e)
            {
                if (ExceptionOccurred != null)
                {
                    ExceptionOccurred(this, new Sunctum.Domain.Models.Managers.ExceptionOccurredEventArgs(e));
                }
            }
            finally
            {
                lock (_lockObj)
                {
                    IsRunning = false;
                }
            }
        }
Esempio n. 20
0
        private void OnGUI()
        {
            AnimationCurveEditor.AutoTangentMode = AutoTangentMode;
            AnimationHelper.IsInAnimationMode    = IsInAnimationMode;

            if (!CurrentSequence)
            {
                ShowNotification(new GUIContent(USEditorUtility.SelectSequence));
            }
            if (CurrentSequence && CurrentSequence.TimelineContainerCount <= 1)
            {
                ShowNotification(new GUIContent(USEditorUtility.NoAnimatableObjects));
            }

            if (CurrentSequence && CurrentSequence.TimelineContainerCount > 1 && EditorApplication.timeSinceStartup - showAnimationModeTime > 3000)
            {
                RemoveNotification();
            }

            using (new Shared.GUIBeginVertical())
            {
                DisplayTopBar();
                DisplayEdittableArea();
                DisplayBottomBar();
            }

            ProcessHotkeys();

            if (Event.current.type == EventType.DragUpdated)
            {
                if (!AnimationHelper.IsInAnimationMode)
                {
                    DragAndDrop.visualMode = DragAndDropVisualMode.Link;
                    Event.current.Use();
                }
                else
                {
                    showAnimationModeTime = EditorApplication.timeSinceStartup;
                    ShowNotification(new GUIContent(USEditorUtility.AddingNewAffectedObjectWhilstInAnimationMode));
                }
            }

            if (Event.current.type == EventType.DragPerform)
            {
                if (!AnimationHelper.IsInAnimationMode)
                {
                    foreach (var dragObject in DragAndDrop.objectReferences)
                    {
                        var GO = dragObject as GameObject;
                        if (GO != CurrentSequence.gameObject)
                        {
                            DragAndDrop.AcceptDrag();

                            //Do we already have a timeline for this object
                            foreach (var timelineContainer in CurrentSequence.TimelineContainers)
                            {
                                if (timelineContainer.AffectedObject == GO.transform)
                                {
                                    return;
                                }
                            }

                            var newTimelineContainer = CurrentSequence.CreateNewTimelineContainer(GO.transform);
                            USUndoManager.RegisterCreatedObjectUndo(newTimelineContainer.gameObject, "Add New Timeline Container");
                            ContentRenderer.AddNewTimelineContainer(newTimelineContainer);
                        }
                    }

                    Event.current.Use();
                }
            }
        }
Esempio n. 21
0
 /// <summary>Gets the last mapper to use.</summary>
 /// <typeparam name="TMapper">Type of the mapper.</typeparam>
 /// <returns>
 /// An object allowing the return to the beginning of the fluent specification (the parent repo
 /// spec).
 /// </returns>
 public IRepositorySpec Finally <TMapper>() where TMapper : IMapper
 {
     AddMapper(typeof(TMapper));
     ParentSpec.MapperOrder.SetSequence(CurrentSequence.ToArray());
     return(ParentSpec);
 }
Esempio n. 22
0
 /// <summary>Adds a mapper to the existing sequence.</summary>
 /// <param name="mapperType">Type of the mapper to add.</param>
 private void AddMapper(Type mapperType)
 {
     CurrentSequence.Add(mapperType);
 }
Esempio n. 23
0
        private void SequenceUpdate()
        {
            if (PropertyBoxPopup.OpenCooldown >= 0.0f)
            {
                var currentTime = Time.realtimeSinceStartup;
                var deltaTime   = currentTime - PreviousTime;
                PropertyBoxPopup.OpenCooldown = PropertyBoxPopup.OpenCooldown - deltaTime;
            }
            PropertyBoxPopup.OpenCooldown = Mathf.Clamp(PropertyBoxPopup.OpenCooldown, 0.0f, 1.0f);

            if (CurrentSequence)
            {
                var currentTime = Time.realtimeSinceStartup;
                var deltaTime   = currentTime - PreviousTime;

                if (Mathf.Abs(deltaTime) > USSequencer.SequenceUpdateRate)
                {
                    if (CurrentSequence.IsPlaying && !Application.isPlaying)
                    {
                        CurrentSequence.UpdateSequencer(deltaTime * Time.timeScale);
                        Repaint();
                    }
                    PreviousTime = currentTime;
                }
            }

            USSequencer nextSequence = null;

            if (Selection.activeGameObject != null && (CurrentSequence == null || Selection.activeGameObject != CurrentSequence.gameObject))
            {
                nextSequence = Selection.activeGameObject.GetComponent <USSequencer>();
                if (nextSequence != null)
                {
                    var isPrefab = PrefabUtility.GetPrefabParent(nextSequence.gameObject) == null && PrefabUtility.GetPrefabObject(nextSequence.gameObject) != null;
                    if (isPrefab)
                    {
                        nextSequence = null;
                    }
                }
            }
            else
            {
                return;
            }

            if (nextSequence == null)
            {
                return;
            }

            if (!Application.isPlaying && CurrentSequence != nextSequence)
            {
                ShowOnlyAnimated = false;

                if (CurrentSequence)
                {
                    CurrentSequence.Stop();
                }

                if (nextSequence)
                {
                    nextSequence.Stop();
                }

                StopProcessingAnimationMode();
            }

            SequenceSwitch(nextSequence);

            Repaint();
        }
Esempio n. 24
0
        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);
                    }
                }
            }
        }