Beispiel #1
0
 ///Delete a track of this group
 public void DeleteTrack(CutsceneTrack track)
 {
     UnityEditor.Undo.RegisterCompleteObjectUndo(this, "Delete Track");
     tracks.Remove(track);
     if (ReferenceEquals(CutsceneUtility.selectedObject, track))
     {
         CutsceneUtility.selectedObject = null;
     }
     UnityEditor.Undo.DestroyObjectImmediate(track.gameObject);
     root.Validate();
 }
Beispiel #2
0
        ///Paste a previously copied clip. Creates a new clip with copied values within the target track.
        public static ActionClip PasteClip(CutsceneTrack track, float time)
        {
            if (copyType != null && !string.IsNullOrEmpty(copyJson))
            {
                var newAction = track.AddAction(copyType, time);
                JsonUtility.FromJsonOverwrite(copyJson, newAction);
                newAction.startTime = time;

                var nextAction = track.clips.FirstOrDefault(a => a.startTime > newAction.startTime);
                if (nextAction != null && newAction.endTime > nextAction.startTime)
                {
                    newAction.endTime = nextAction.startTime;
                }

                return(newAction);
            }
            return(null);
        }
Beispiel #3
0
        ///Duplicate the track in this group
        public CutsceneTrack DuplicateTrack(CutsceneTrack track)
        {
            if (!CanAddTrack(track))
            {
                return(null);
            }

            var newTrack = (CutsceneTrack)Instantiate(track);

            UnityEditor.Undo.RegisterCreatedObjectUndo(newTrack.gameObject, "Duplicate Track");
            UnityEditor.Undo.SetTransformParent(newTrack.transform, this.transform, "Duplicate Track");
            UnityEditor.Undo.RegisterCompleteObjectUndo(this, "Duplicate Track");
            newTrack.transform.localPosition = Vector3.zero;
            tracks.Add(newTrack);
            root.Validate();
            CutsceneUtility.selectedObject = newTrack;
            return(newTrack);
        }
Beispiel #4
0
        ///Duplicate the track in this group
        public CutsceneTrack DuplicateTrack(CutsceneTrack track)
        {
            if (track == null || track.GetType().RTGetAttribute <UniqueElementAttribute>(true) != null)
            {
                return(null);
            }

            var newTrack = (CutsceneTrack)Instantiate(track);

            UnityEditor.Undo.RegisterCreatedObjectUndo(newTrack.gameObject, "Duplicate Track");
            UnityEditor.Undo.SetTransformParent(newTrack.transform, this.transform, "Duplicate Track");
            UnityEditor.Undo.RegisterCompleteObjectUndo(this, "Duplicate Track");
            newTrack.transform.localPosition = Vector3.zero;
            tracks.Add(newTrack);
            root.Validate();
            CutsceneUtility.selectedObject = newTrack;
            return(newTrack);
        }
Beispiel #5
0
        ///Delete a track of this group
        public void DeleteTrack(CutsceneTrack track)
        {
#if UNITY_2018_3_OR_NEWER
            if (!track.gameObject.IsSafePrefabDelete())
            {
                UnityEditor.EditorUtility.DisplayDialog("Delete Track", "This track is part of the prefab asset and can not be deleted from within the prefab instance. If you want to delete the track, please open the prefab asset for editing.", "OK");
                return;
            }
#endif

            UnityEditor.Undo.RegisterCompleteObjectUndo(this, "Delete Track");
            tracks.Remove(track);
            if (ReferenceEquals(CutsceneUtility.selectedObject, track))
            {
                CutsceneUtility.selectedObject = null;
            }
            UnityEditor.Undo.DestroyObjectImmediate(track.gameObject);
            root.Validate();
        }
Beispiel #6
0
        ///----------------------------------------------------------------------------------------------
        ///---------------------------------------UNITY EDITOR-------------------------------------------
#if UNITY_EDITOR
        ///Can track be added in this group?
        public bool CanAddTrack(CutsceneTrack track)
        {
            return(track != null?CanAddTrackOfType(track.GetType()) : false);
        }