public static void AddRootTrack(this XTimeline timeline, XTrack track) { var tracks = timeline.trackTrees.ToList(); tracks.Add(track); timeline.trackTrees = tracks.ToArray(); }
public static void Remove(this XTrack track, XTimeline timeline) { if (track.parent) { var chs = track.parent.childs; int idx = -1; for (int i = 0; i < chs.Length; i++) { if (chs[i].Equals(track)) { idx = i; break; } } if (idx >= 0) { track.parent.RemoveChild(idx); } } else { var list = timeline.trackTrees.ToList(); if (list.Contains(track)) { list.Remove(track); timeline.trackTrees = list.ToArray(); } } track.OnDestroy(); }
public static void GetTrackByDataType(Type type, XTimeline timeline, XTrack parent, Action <XTrack, TrackData, object> cb) { TrackData data = CreateTrackData(type); if (data != null) { if (type == typeof(XAnimationTrack)) { CharacterWindow.ShowWindow(ch => { if (ch != null) { var bd = data as AnimationTrackData; bd.prefab = ch.prefab; bd.roleid = ch.id; cb(XTimelineFactory.GetTrack(data, timeline, parent), data, ch); } else { cb(null, data, null); } }); } else { cb(XTimelineFactory.GetTrack(data, timeline, parent), data, null); } } else { cb(null, null, null); } }
public void CheckExist() { if (timeline == null && Application.isPlaying) { var run = Object.FindObjectOfType <RuntimeTimeline>(); if (run) { timeline = run.timeline; } } }
public void Open(string path, PlayMode mode) { Dispose(); this.path = path; timeline = new XTimeline(path, mode); timeline.Finish = OnPlayFinish; AddRuntime(); float dur = timeline.RecalcuteDuration(); window.SetTimeRange(0, dur * 1.5f); }
public void Dispose() { path = string.Empty; CleanEnv(); RebuildInspector(); timeline?.Dispose(); timeline = null; if (window != null) { window.Dispose(); } XResources.Clean(); }
public static void BuildConf(this XTimeline timeline) { var tree = timeline.trackTrees; if (tree != null) { int len = tree.Length; timeline.config.tracks = new TrackData[len]; for (int i = 0; i < len; i++) { timeline.config.tracks[i] = tree[i].data; } } }
private void OnPlayChanged(PlayModeStateChange state) { if (state == PlayModeStateChange.ExitingEditMode || state == PlayModeStateChange.ExitingPlayMode || state == PlayModeStateChange.EnteredEditMode) { timeline?.Dispose(); timeline = null; CleanEnv(); if (window != null) { window.Dispose(); window.Repaint(); } } }
private void Play(string name) { Debug.Log("play: " + name); time = Time.time; string path = "Assets/skill/" + name + ".xml"; if (timeline == null) { timeline = new XTimeline(path, PlayMode.Skill); timeline.SetPlaying(true); } else { timeline.BlendTo(path); } }
public void CreateTimeline(string path, PlayMode mode) { Dispose(); this.path = path; TimelineConfig xconf = new TimelineConfig(); xconf.tracks = new TrackData[1]; TrackData data = new TrackData(); data.type = AssetType.Marker; xconf.tracks[0] = data; xconf.Write(path); timeline = new XTimeline(xconf, mode); timeline.Finish = OnPlayFinish; AddRuntime(); timeline.Time = 1.0f; timeline.editMode = TimelinePlayMode.EditorRun; }