Beispiel #1
0
        static bool HandleTrackAndItemCreation(IEnumerable <UnityEngine.Object> objectsBeingDropped, double candidateTime, TypeResolver typeResolver, TimelineAsset timeline, TrackAsset parent, IEnumerable <Type> validTrackTypes, TrackAsset insertBefore = null)
        {
            Action <Type> onResolved = t =>
            {
                var newTrack = timeline.CreateTrack(t, parent, string.Empty);
                if (insertBefore != null)
                {
                    if (parent != null)
                    {
                        parent.MoveLastTrackBefore(insertBefore);
                    }
                    else
                    {
                        timeline.MoveLastTrackBefore(insertBefore);
                    }
                }
                HandleItemCreation(objectsBeingDropped, newTrack, candidateTime, typeResolver, validTrackTypes.Count() == 1); // menu is popped if ambiguous clip choice and unambiguous track choice

                if (parent != null)
                {
                    parent.SetCollapsed(false);
                }

                TimelineEditor.Refresh(RefreshReason.ContentsAddedOrRemoved);
            };

            return(typeResolver(validTrackTypes, t => onResolved(t), k_SelectTrackWithClip)); // Did it create a track
        }
Beispiel #2
0
//----------------------------------------------------------------------------------------------------------------------
        public void Execute()
        {
            //Only continue preloading images when we are not in play mode
            if (Application.isPlaying)
            {
                return;
            }

            Assert.IsNotNull(m_mixer);

            var  clipAssets   = m_mixer.GetClipAssets();
            bool needsRefresh = false;

            foreach (KeyValuePair <TimelineClip, StreamingImageSequencePlayableAsset> kv in clipAssets)
            {
                StreamingImageSequencePlayableAsset sisAsset = kv.Value;
                sisAsset.ContinuePreloadingImages();

                if (sisAsset.UpdateTextureWithRequestedImage())
                {
                    needsRefresh = true;
                }
            }

            if (needsRefresh)
            {
                TimelineEditor.Refresh(RefreshReason.ContentsModified);
            }
        }
 private void OnRemoveControl(int index)
 {
     serializedObject.Update();
     _controls.DeleteArrayElementAtIndex(index);
     serializedObject.ApplyModifiedProperties();
     TimelineEditor.Refresh(RefreshReason.ContentsModified);
 }
Beispiel #4
0
        public void ClearAllClips()
        {
            var asset = TimelineEditor.inspectedAsset;

            if (asset == null)
            {
                var trackAsset    = clipList[0].parentTrack;
                var timelineAsset = trackAsset.timelineAsset;
                for (int i = 0; i < clipList.Count; i++)
                {
                    timelineAsset.DeleteClip(clipList[i]);
                }
                clipList.Clear();
                return;
            }

            foreach (var track in asset.GetRootTracks())
            {
                if (track is DialogueTrack)
                {
                    var clips = track.GetClips();
                    foreach (var clip in clips)
                    {
                        asset.DeleteClip(clip);
                    }
                    //var markers = track.GetMarkers();
                    //foreach (var m in markers)
                    //{
                    //    track.DeleteMarker(m);
                    //}
                }
            }
            TimelineEditor.Refresh(RefreshReason.ContentsAddedOrRemoved);
            TimelineEditor.Refresh(RefreshReason.ContentsModified);
        }
    public override void OnGUI(string searchContext)
    {
        m_SerializedObject.Update();
        EditorGUI.BeginChangeCheck();
        using (new SettingsWindow.GUIScope())
        {
            EditorGUILayout.LabelField(Styles.EditorSettingLabel, EditorStyles.boldLabel);
            m_TimeFormat.enumValueIndex                 = EditorGUILayout.Popup(Styles.TimeUnitLabel, m_TimeFormat.enumValueIndex, m_TimeFormat.enumDisplayNames);
            m_PlaybackScrollMode.enumValueIndex         = EditorGUILayout.Popup(Styles.PlaybackScrollModeLabel, m_PlaybackScrollMode.enumValueIndex, m_PlaybackScrollMode.enumNames);
            m_ShowAudioWaveform.boolValue               = EditorGUILayout.Toggle(Styles.ShowAudioWaveformLabel, m_ShowAudioWaveform.boolValue);
            TimelinePreferences.instance.audioScrubbing = EditorGUILayout.Toggle(Styles.AudioScrubbingLabel, TimelinePreferences.instance.audioScrubbing);
            m_SnapToFrame.boolValue = EditorGUILayout.Toggle(Styles.SnapToFrameLabel, m_SnapToFrame.boolValue);
            m_EdgeSnap.boolValue    = EditorGUILayout.Toggle(Styles.EdgeSnapLabel, m_EdgeSnap.boolValue);
#if TIMELINE_FRAMEACCURATE
            m_PlaybackLockedToFrame.boolValue = EditorGUILayout.Toggle(Styles.PlaybackLockedToFrame, m_PlaybackLockedToFrame.boolValue);
#endif
        }
        if (EditorGUI.EndChangeCheck())
        {
            m_SerializedObject.ApplyModifiedProperties();
            TimelinePreferences.instance.Save();
            TimelineEditor.Refresh(RefreshReason.WindowNeedsRedraw);
            TimelineEditor.RefreshPreviewPlay();
        }
    }
Beispiel #6
0
        public override void OnInspectorGUI()
        {
            base.OnInspectorGUI();
            EditorGUILayout.LabelField("Configured Timelines", EditorStyles.boldLabel);
            var playableDirector = serializedObject.targetObject as PlayableDirector;

            if (playableDirector == null)
            {
                return;
            }
            _timelineAssets = _timelineAssets ?? Resources.FindObjectsOfTypeAll <TimelineAsset>();
            TimelineAsset[] configuredTimelines = _timelineAssets
                                                  .Where(timelineAsset => timelineAsset.GetOutputTracks()
                                                         .Any(track => playableDirector.GetGenericBinding(track) != null))
                                                  .ToArray();

            foreach (TimelineAsset timelineAsset in configuredTimelines)
            {
                GUILayout.BeginHorizontal();
                GUILayout.Space(20);
                GUI.enabled = false;
                EditorGUILayout.ObjectField(timelineAsset, typeof(TimelineAsset), false);
                GUI.enabled = true;
                if (GUILayout.Button("Select"))
                {
                    playableDirector.playableAsset = timelineAsset;
                    TimelineEditor.Refresh(RefreshReason.ContentsModified);
                }

                GUILayout.EndHorizontal();
            }
        }
Beispiel #7
0
        public override void OnInspectorGUI()
        {
            serializedObject.Update();

            using (var changeScope = new EditorGUI.ChangeCheckScope())
            {
                var property = serializedObject.GetIterator();
                var expanded = true;
                while (property.NextVisible(expanded))
                {
                    expanded = false;
                    if (SkipField(property.propertyPath))
                    {
                        continue;
                    }
                    EditorGUILayout.PropertyField(property, true);
                }

                DrawSignalFlags();
                UpdateState();
                DrawNameSelectorAndSignalList();

                if (changeScope.changed)
                {
                    serializedObject.ApplyModifiedProperties();
                    TimelineEditor.Refresh(RefreshReason.ContentsModified | RefreshReason.WindowNeedsRedraw);
                }
            }
        }
Beispiel #8
0
 public void RemoveColorKeyframe(ColorKeyframe keyframe)
 {
     Track.DeleteMarker(keyframe);
     UpdateView();
     UpdateProperties();
     TimelineEditor.Refresh(RefreshReason.ContentsAddedOrRemoved);
 }
Beispiel #9
0
        public override void OnInspectorGUI()
        {
            serializedObject.Update();

            EditorGUILayout.PropertyField(_controlMode);
            EditorGUILayout.Space();

            MidiControlDrawer.ControlMode = (MidiControlMode)_controlMode.enumValueIndex;

            EditorGUI.BeginChangeCheck();

            for (var i = 0; i < _controls.arraySize; i++)
            {
                DrawSplitter();
                DrawHeader(i);
                EditorGUILayout.Space();
                EditorGUILayout.PropertyField(_controls.GetArrayElementAtIndex(i));
                EditorGUILayout.Space();
            }

            if (EditorGUI.EndChangeCheck())
            {
                TimelineEditor.Refresh(RefreshReason.ContentsModified);
            }

            DrawSplitter();

            EditorGUILayout.Space();
            if (GUILayout.Button("Add Control Element"))
            {
                _controls.InsertArrayElementAtIndex(_controls.arraySize);
            }

            serializedObject.ApplyModifiedProperties();
        }
Beispiel #10
0
 protected override void OnEnable()
 {
     base.OnEnable();
     targetPoint = 0;
     TimelineUtilities.Director.time = Target.time;
     TimelineEditor.Refresh(RefreshReason.ContentsAddedOrRemoved);
 }
Beispiel #11
0
        public TrackAsset CreateTrack(Type _trackAssetType, string _path)
        {
#if UNITY_2018_1_OR_NEWER
            TimelineLiteAsset timelineLiteAsset = TimelineEditor.inspectedAsset as TimelineLiteAsset;
#else
            TimelineLiteAsset timelineLiteAsset = TimelineEditor.timelineAsset as TimelineLiteAsset;
#endif
            TrackAsset trackAsset = null;
            if (timelineLiteAsset != null)
            {
                string name = _path.Substring(_path.LastIndexOf("/") + 1);

                if (Selection.activeObject is UnityEngine.Timeline.GroupTrack)
                {
                    trackAsset = timelineLiteAsset.CreateTrack(_trackAssetType, Selection.activeObject as UnityEngine.Timeline.GroupTrack, name);
                }
                else
                {
                    trackAsset = timelineLiteAsset.CreateTrack(_trackAssetType, null, name);
                }
#if UNITY_2018_1_OR_NEWER
                TimelineEditor.Refresh(RefreshReason.ContentsAddedOrRemoved);
#endif
            }
            return(trackAsset);
        }
        static void RefreshTimelineEditor()
        {
#if UNITY_2018_3_OR_NEWER
            TimelineEditor.Refresh(RefreshReason.ContentsAddedOrRemoved);
#else
            object[] noParameters = new object[] { };

            Type timelineType = typeof(TimelineEditor);

            Assembly assembly   = timelineType.Assembly;
            Type     windowType = assembly.GetType("UnityEditor.Timeline.TimelineWindow");

            PropertyInfo windowInstanceProperty = windowType.GetProperty("instance");
            object       windowInstance         = windowInstanceProperty.GetValue(null, noParameters);

            if (windowInstance == null)
            {
                return;
            }

            PropertyInfo windowStateProperty = windowType.GetProperty("state");
            object       windowState         = windowStateProperty.GetValue(windowInstance, noParameters);

            if (windowState == null)
            {
                return;
            }

            Type       windowStateType = windowState.GetType();
            MethodInfo refreshMethod   = windowStateType.GetMethod("Refresh", new Type[] { });

            refreshMethod.Invoke(windowState, noParameters);
#endif
        }
        public IEnumerator ShowFrameMarkers()
        {
            PlayableDirector director = EditorUtilityTest.NewSceneWithDirector();
            TimelineClip     clip     = EditorUtilityTest.CreateTestTimelineClip(director);
            StreamingImageSequencePlayableAsset sisAsset = clip.asset as StreamingImageSequencePlayableAsset;

            Assert.IsNotNull(sisAsset);
            yield return(null);

            //Show
            TimelineClipSISData timelineClipSISData = sisAsset.GetBoundTimelineClipSISData();

            TrackAsset trackAsset = clip.parentTrack;

            timelineClipSISData.RequestFrameMarkers(true, true);
            TimelineEditor.Refresh(RefreshReason.ContentsModified);
            yield return(null);

            Assert.AreEqual(TimelineUtility.CalculateNumFrames(clip), trackAsset.GetMarkerCount());
            yield return(null);


            //Undo showing FrameMarkers
            EditorUtilityTest.UndoAndRefreshTimelineEditor(); yield return(null);

            Assert.False(timelineClipSISData.AreFrameMarkersRequested());
            Assert.AreEqual(0, trackAsset.GetMarkerCount());


            EditorUtilityTest.DestroyTestTimelineAssets(clip);
            yield return(null);
        }
    public override void OnInspectorGUI()
    {
        serializedObject.Update();
        var marker = target as JumpMarker;

        using (var changeScope = new EditorGUI.ChangeCheckScope())
        {
            EditorGUILayout.PropertyField(m_Time);
            EditorGUILayout.Space();

            var destinationMarkers = DestinationMarkersFor(marker);
            if (!destinationMarkers.Any())
            {
                DrawNoJump();
            }
            else
            {
                DrawJumpOptions(destinationMarkers);
            }

            if (changeScope.changed)
            {
                serializedObject.ApplyModifiedProperties();
                TimelineEditor.Refresh(RefreshReason.ContentsModified);
            }
        }
    }
Beispiel #15
0
    public void SetWaypoint(Vector3 position, float time)
    {
        List <Waypoint> waypoints = this.Waypoints;

        if (waypoints == null)
        {
            return;
        }

        Waypoint keyframe = GetKeyframe(waypoints, time) as Waypoint;

        if (keyframe == null)
        {
            Vector3 tangent = 0.125f * KeyframeUtil.GetTangent(waypoints, time, true, true);
            keyframe           = Track.CreateMarker <Waypoint>(time);
            keyframe.JointType = JointType.Continuous;
            keyframe.Tangent   = tangent;

            TimelineEditor.Refresh(RefreshReason.ContentsAddedOrRemoved);
            UpdateProperties();
            EnforceWaypointConstraints();
        }

        bool endpoint = (waypoints.Count == 0) || (time > waypoints[waypoints.Count - 1].time);

        Undo.RecordObjects(new Object[] { keyframe }, "Change Waypoints");
        keyframe.Position = position;

        if (endpoint)
        {
            keyframe.JointType = JointType.Linear;
        }

        UpdateView();
    }
Beispiel #16
0
    public override void OnInspectorGUI()
    {
        BeginInspector();
        SerializedProperty vcamProperty = FindProperty(x => x.VirtualCamera);

        EditorGUI.indentLevel = 0;     // otherwise subeditor layouts get screwed up

        AutoCreateShotFromSceneView
            = EditorGUILayout.Toggle(
                  new GUIContent(
                      "Auto-create new shots", "When enabled, new clips will be "
                      + "automatically populated to match the scene view camera"),
                  AutoCreateShotFromSceneView);

        Rect rect;
        CinemachineVirtualCameraBase vcam
            = vcamProperty.exposedReferenceValue as CinemachineVirtualCameraBase;

        if (vcam != null)
        {
            EditorGUILayout.PropertyField(vcamProperty, kVirtualCameraLabel);
        }
        else
        {
            GUIContent createLabel = new GUIContent("Create");
            Vector2    createSize  = GUI.skin.button.CalcSize(createLabel);

            rect        = EditorGUILayout.GetControlRect(true);
            rect.width -= createSize.x;

            EditorGUI.PropertyField(rect, vcamProperty, kVirtualCameraLabel);
            rect.x += rect.width; rect.width = createSize.x;
            if (GUI.Button(rect, createLabel))
            {
                vcam = CreateStaticVcamFromSceneView();
                vcamProperty.exposedReferenceValue = vcam;
            }
            serializedObject.ApplyModifiedProperties();
        }

        EditorGUI.BeginChangeCheck();
        DrawRemainingPropertiesInInspector();

        if (vcam != null)
        {
            DrawSubeditors(vcam);
        }

        // by default timeline rebuilds the entire graph when something changes,
        // but if a property of the virtual camera changes, we only need to re-evaluate the timeline.
        // this prevents flicker on post processing updates
        if (EditorGUI.EndChangeCheck())
        {
#if UNITY_2018_3_OR_NEWER
            TimelineEditor.Refresh(RefreshReason.SceneNeedsUpdate);
#endif
            GUI.changed = false;
        }
    }
        private void OnResetControl(int index)
        {
            var track = (MidiAnimationTrack)target;

            Undo.RecordObject(track, "Reset MIDI Control");
            track.template.controls[index] = new MidiControl();
            TimelineEditor.Refresh(RefreshReason.ContentsModified);
        }
Beispiel #18
0
 static void RenderCacheTrack_OnUndoRedoPerformed()
 {
     if (null == TimelineEditor.inspectedDirector)
     {
         return;
     }
     TimelineEditor.Refresh(RefreshReason.ContentsAddedOrRemoved);
 }
Beispiel #19
0
 public void RemoveWaypoint(Waypoint waypoint)
 {
     Track.DeleteMarker(waypoint);
     UpdateView();
     UpdateProperties();
     TimelineEditor.Refresh(RefreshReason.ContentsAddedOrRemoved);
     EnforceWaypointConstraints();
 }
Beispiel #20
0
        void RefreshReasonExample()
        {
            #region declare-refreshReason

            TimelineEditor.Refresh(RefreshReason.ContentsModified | RefreshReason.SceneNeedsUpdate);

            #endregion
        }
        private void OnPasteControl(int index)
        {
            var track = (MidiAnimationTrack)target;

            Undo.RecordObject(track, "Paste MIDI Control");
            CopyControl(_clipboard, track.template.controls[index], true);
            TimelineEditor.Refresh(RefreshReason.ContentsModified);
        }
Beispiel #22
0
        static void StreamingImageSequenceTrack_OnUndoRedoPerformed()
        {
            if (null == TimelineEditor.inspectedDirector)
            {
                return;
            }

            TimelineEditor.Refresh(RefreshReason.ContentsAddedOrRemoved);
        }
//----------------------------------------------------------------------------------------------------------------------

        internal static void ResizeSISTimelineClip(TimelineClip clip, double duration)
        {
#if UNITY_EDITOR
            Undo.RegisterCompleteObjectUndo(clip.parentTrack, "StreamingImageSequence: Set Duration");
#endif
            clip.duration = duration;

            TimelineEditor.Refresh(RefreshReason.ContentsModified);
        }
Beispiel #24
0
        public static DragAndDropVisualMode HandleHierarchyPaneDragAndDrop(IEnumerable <UnityObject> objectsBeingDropped, TrackAsset targetTrack, bool perform, TimelineAsset timeline, PlayableDirector director, TypeResolver typeResolver, TrackAsset insertBefore = null)
        {
            if (timeline == null)
            {
                return(DragAndDropVisualMode.Rejected);
            }

            // if we are over a target track, defer to track binding system (implemented in TrackGUIs), unless we are a groupTrack
            if (targetTrack != null && (targetTrack as GroupTrack) == null)
            {
                return(DragAndDropVisualMode.None);
            }

            if (targetTrack != null && targetTrack.lockedInHierarchy)
            {
                return(DragAndDropVisualMode.Rejected);
            }

            var tracksWithBinding = objectsBeingDropped.SelectMany(TypeUtility.GetTracksCreatableFromObject).Distinct();

            if (!tracksWithBinding.Any())
            {
                return(DragAndDropVisualMode.None);
            }

            if (perform)
            {
                System.Action <Type> onResolve = trackType =>
                {
                    foreach (var obj in objectsBeingDropped)
                    {
                        if (!obj.IsPrefab() && TypeUtility.IsTrackCreatableFromObject(obj, trackType))
                        {
                            var newTrack = TimelineHelpers.CreateTrack(timeline, trackType, targetTrack, string.Empty);
                            if (insertBefore != null)
                            {
                                if (targetTrack != null)
                                {
                                    targetTrack.MoveLastTrackBefore(insertBefore);
                                }
                                else
                                {
                                    timeline.MoveLastTrackBefore(insertBefore);
                                }
                            }

                            TimelineHelpers.Bind(newTrack, obj, director);
                        }
                    }
                    TimelineEditor.Refresh(RefreshReason.ContentsAddedOrRemoved);
                };
                typeResolver(tracksWithBinding, onResolve, k_SelectTrackWithBinding);
            }

            return(DragAndDropVisualMode.Copy);
        }
Beispiel #25
0
//----------------------------------------------------------------------------------------------------------------------

    private void CreateClipCurve(TimelineClip clip) {        
        clip.CreateCurves("Curves: " + clip.displayName);
        
        //Init dummy linear curve
        AnimationCurve curve = AnimationCurve.Linear(0f,0f,(float)clip.duration,1f);
        AnimationUtility.SetEditorCurve(clip.curves, SceneCachePlayableAsset.GetTimeCurveBinding(),curve);
        TimelineEditor.Refresh(RefreshReason.ContentsAddedOrRemoved );
        
        
    }
Beispiel #26
0
//----------------------------------------------------------------------------------------------------------------------


        private static void SetTimelineClipCurve(TimelineClip destClip, AnimationCurve srcCurve, EditorCurveBinding curveBinding)
        {
            AnimationUtility.SetEditorCurve(destClip.curves, curveBinding, srcCurve);

#if AT_USE_TIMELINE_GE_1_5_0
            TimelineEditor.Refresh(RefreshReason.WindowNeedsRedraw);
#else
            TimelineEditor.Refresh(RefreshReason.ContentsAddedOrRemoved); //must use this for Pre- 1.5.0
#endif //AT_USE_TIMELINE_GE_1_5_0
        }
//----------------------------------------------------------------------------------------------------------------------

        #region PlayableFrames

        internal void ResetPlayableFrames()
        {
#if UNITY_EDITOR
            Undo.RegisterCompleteObjectUndo(this, "Resetting PlayableFrames");
#endif
            GetBoundClipData()?.ResetPlayableFrames(); //Null check. the data might not have been bound during recompile

#if UNITY_EDITOR
            TimelineEditor.Refresh(RefreshReason.ContentsAddedOrRemoved);
#endif
        }
//----------------------------------------------------------------------------------------------------------------------

        #region PlayableFrames

        internal void ResetPlayableFrames()
        {
#if UNITY_EDITOR
            Undo.RegisterCompleteObjectUndo(this, "TimelineClipSISDataPlayableAsset: Resetting PlayableFrames");
#endif
            m_timelineClipSISData.ResetPlayableFrames();

#if UNITY_EDITOR
            TimelineEditor.Refresh(RefreshReason.ContentsAddedOrRemoved);
#endif
        }
Beispiel #29
0
    private void OnDestroy()
    {
        CrazyflieTrack crazyflieTrack = this.track as CrazyflieTrack;

        if (crazyflieTrack != null && !TrackLocked)
        {
            crazyflieTrack.ResetReferences();
            TimelineUtilities.Timeline.DeleteTrack(crazyflieTrack);
            TimelineEditor.Refresh(RefreshReason.ContentsAddedOrRemoved);
        }
    }
Beispiel #30
0
        public IEnumerator CreatePlayableAsset()
        {
            EditorSceneManager.NewScene(NewSceneSetup.DefaultGameObjects);

            Color            col        = Color.green;
            GameObject       directorGo = new GameObject("Director");
            PlayableDirector director   = directorGo.AddComponent <PlayableDirector>();

            //Create timeline asset
            TimelineAsset asset = ScriptableObject.CreateInstance <TimelineAsset>();

            director.playableAsset = asset;

            //Create empty asset
            FaderPlayableAsset faderAsset = ScriptableObject.CreateInstance <FaderPlayableAsset>();
            FaderTrack         faderTrack = asset.CreateTrack <FaderTrack>(null, "Footage");
            TimelineClip       clip       = faderTrack.CreateDefaultClip();

            clip.asset = faderAsset;
            faderAsset.SetFadeType(FadeType.FADE_IN);
            faderAsset.SetColor(col);

            //Create new Image
            Transform canvasT = UIUtility.CreateCanvas();

            GameObject imageObj = new GameObject("Image");

            imageObj.transform.SetParent(canvasT);
            Image image = imageObj.AddComponent <Image>();

            director.SetGenericBinding(faderTrack, image);

            //Select gameObject and open Timeline Window. This will trigger the TimelineWindow's update etc.
            EditorApplication.ExecuteMenuItem("Window/Sequencing/Timeline");
            Selection.activeTransform = directorGo.transform;
            yield return(null);

            TimelineEditor.selectedClip = clip;
            yield return(null);

            //FadeIn
            Color zeroAlphaCol = col;

            zeroAlphaCol.a = 0;
            Assert.AreEqual(zeroAlphaCol, image.color);

            //FadeOut
            faderAsset.SetFadeType(FadeType.FADE_OUT);
            TimelineEditor.Refresh(RefreshReason.ContentsModified);
            yield return(null); //Give time for the Timeline Window to update.

            Assert.AreEqual(col, image.color);
        }