コード例 #1
0
ファイル: DialogueTrack.cs プロジェクト: fkxp123/unity
        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);
        }
コード例 #2
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();
            }
        }
//----------------------------------------------------------------------------------------------------------------------
    
    internal static void ShowTimelineWindow() {
#if !AT_USE_TIMELINE_GE_1_5_0            
        EditorApplication.ExecuteMenuItem("Window/Sequencing/Timeline");        
#else 
        TimelineEditor.GetOrCreateWindow();
#endif
    }
コード例 #4
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
        }
コード例 #5
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);
            }
        }
コード例 #6
0
                public static EventEditorGUI CreateEventEditorGUI(TimelineEditor editor, Event evnt)
                {
                    if (_editorGUIConstructorMap == null)
                    {
                        _editorGUIConstructorMap = new Dictionary <Type, Type>();
                        Type[] types = SystemUtils.GetAllSubTypes(typeof(EventEditorGUI));

                        foreach (Type type in types)
                        {
                            EventCustomEditorGUIAttribute eventAttribute = SystemUtils.GetAttribute <EventCustomEditorGUIAttribute>(type);
                            if (eventAttribute != null)
                            {
                                _editorGUIConstructorMap.Add(eventAttribute.EventType, type);
                            }
                        }
                    }

                    //Check for custom editor class
                    Type editorGUIType;

                    if (!_editorGUIConstructorMap.TryGetValue(evnt.GetType(), out editorGUIType))
                    {
                        //Use generic editor gui class
                        editorGUIType = typeof(EventEditorGUI);
                    }

                    EventEditorGUI editorGUI = (EventEditorGUI)EventEditorGUI.CreateInstance(editorGUIType);

                    editorGUI.Init(editor, evnt);

                    return(editorGUI);
                }
コード例 #7
0
 public void RemoveColorKeyframe(ColorKeyframe keyframe)
 {
     Track.DeleteMarker(keyframe);
     UpdateView();
     UpdateProperties();
     TimelineEditor.Refresh(RefreshReason.ContentsAddedOrRemoved);
 }
コード例 #8
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();
    }
コード例 #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();
        }
コード例 #10
0
    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();
        }
    }
コード例 #11
0
 private void OnRemoveControl(int index)
 {
     serializedObject.Update();
     _controls.DeleteArrayElementAtIndex(index);
     serializedObject.ApplyModifiedProperties();
     TimelineEditor.Refresh(RefreshReason.ContentsModified);
 }
コード例 #12
0
 protected override void OnEnable()
 {
     base.OnEnable();
     targetPoint = 0;
     TimelineUtilities.Director.time = Target.time;
     TimelineEditor.Refresh(RefreshReason.ContentsAddedOrRemoved);
 }
コード例 #13
0
        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
        }
コード例 #14
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);
        }
コード例 #15
0
        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);
        }
コード例 #16
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);
                }
            }
        }
コード例 #17
0
    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);
            }
        }
    }
コード例 #18
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;
        }
    }
コード例 #19
0
ファイル: MainWindow.cs プロジェクト: slagusev/SharpGM
        private void newTimelineBt_Click(object sender, EventArgs e)
        {
            TimelineEditor childForm = new TimelineEditor();

            childForm.MdiParent = this;
            childForm.Text      = "Timeline";
            childForm.Show();
        }
コード例 #20
0
 public void RemoveWaypoint(Waypoint waypoint)
 {
     Track.DeleteMarker(waypoint);
     UpdateView();
     UpdateProperties();
     TimelineEditor.Refresh(RefreshReason.ContentsAddedOrRemoved);
     EnforceWaypointConstraints();
 }
コード例 #21
0
        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);
        }
コード例 #22
0
        void RefreshReasonExample()
        {
            #region declare-refreshReason

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

            #endregion
        }
コード例 #23
0
 static void RenderCacheTrack_OnUndoRedoPerformed()
 {
     if (null == TimelineEditor.inspectedDirector)
     {
         return;
     }
     TimelineEditor.Refresh(RefreshReason.ContentsAddedOrRemoved);
 }
コード例 #24
0
        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);
        }
コード例 #25
0
        static void StreamingImageSequenceTrack_OnUndoRedoPerformed()
        {
            if (null == TimelineEditor.inspectedDirector)
            {
                return;
            }

            TimelineEditor.Refresh(RefreshReason.ContentsAddedOrRemoved);
        }
コード例 #26
0
//----------------------------------------------------------------------------------------------------------------------

        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);
        }
コード例 #27
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);
        }
コード例 #28
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 );
        
        
    }
コード例 #29
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
        }
コード例 #30
0
    private void OnDestroy()
    {
        CrazyflieTrack crazyflieTrack = this.track as CrazyflieTrack;

        if (crazyflieTrack != null && !TrackLocked)
        {
            crazyflieTrack.ResetReferences();
            TimelineUtilities.Timeline.DeleteTrack(crazyflieTrack);
            TimelineEditor.Refresh(RefreshReason.ContentsAddedOrRemoved);
        }
    }
コード例 #31
0
ファイル: TimelineEditor.cs プロジェクト: NerdsRUs/Summer2014
	static public void show()
	{
		mTimelineEditor = (TimelineEditor)EditorWindow.GetWindow(typeof(TimelineEditor));

		if (Selection.transforms.Length == 1)
		{
			Timeline tempTimeline = Selection.transforms[0].GetComponent<Timeline>();

			if (tempTimeline != null)
			{
				mTimelineEditor.setActiveTimeline(tempTimeline);

				mTimelineEditor.refreshLayers();
			}
		}
	}