public void DeleteGroup(TrackTreeViewGroup group) { if (_Editor.Matinee != null) { if (UnityEditor.EditorUtility.DisplayDialog("Delete TrackGroup", "Are you sure you want to delete group : " + group.Group.gameObject.name, "Yes", "No")) { ((Skill.Framework.UI.Panel)group.Parent).Controls.Remove(group); RemoveTracks(group); Skill.Editor.UI.EditorFrame.RepaintParentEditorWindow(group); GameObject.DestroyImmediate(group.Group.gameObject); } } }
private void RemoveTracks(TrackTreeViewGroup group) { foreach (var item in group.Controls) { if (item is TrackTreeViewItem) { _Editor.TimeLine.View.Controls.Remove(((TrackTreeViewItem)item).TrackBar); } else if (item is TrackTreeViewGroup) { RemoveTracks((TrackTreeViewGroup)item); } } }
public TrackTreeViewGroupProperties(TrackTreeViewGroup group) : base(group) { _Group = group; _TxtName = new Skill.Editor.UI.TextField() { Margin = ControlMargin }; _TxtName.Label.text = "Name"; _TxtName.TextChanged += _TxtName_TextChanged; Controls.Add(_TxtName); _TxtName.TextChanged += _TxtName_TextChanged; Refresh(); }
private void CreateTrack(TrackTreeViewGroup parent, TrackType type) { if (_Editor.Matinee != null) { GameObject newObj = new GameObject(string.Format("New{0}Track", type.ToString())); Track newTrack = CreateNewTrack(newObj, type); BaseTrackBar bar = CreateNewTrackBar(newTrack); _Editor.TimeLine.View.Controls.Add(bar); TrackTreeViewItem newItem = new TrackTreeViewItem(newTrack, bar); newItem.ContextMenu = _TrackItemContextMenu; newObj.transform.parent = parent.Group.transform; parent.Controls.Add(newItem); parent.Foldout.IsOpen = true; newObj.transform.localPosition = Vector3.zero; newObj.transform.localRotation = Quaternion.identity; } }
private void CreateGroup(TrackTreeViewGroup parent) { if (_Editor.Matinee != null) { GameObject newObj = new GameObject("NewGroup"); TrackTreeViewGroup newG = new TrackTreeViewGroup(newObj.AddComponent <TrackGroup>()); newG.Foldout.Content.text = newG.Group.gameObject.name; newG.ContextMenu = _TrackGroupContextMenu; if (parent != null) { newObj.transform.parent = parent.Group.transform; parent.Controls.Add(newG); parent.Foldout.IsOpen = true; } else { newObj.transform.parent = _Editor.Matinee.transform; _TreeView.Controls.Add(newG); } newObj.transform.localPosition = Vector3.zero; newObj.transform.localRotation = Quaternion.identity; } }
private void TrackGroupProperties_Click(object sender, System.EventArgs e) { TrackTreeViewGroup group = Owner as TrackTreeViewGroup; InspectorProperties.Select(group); }
private void TrackGroupDelete_Click(object sender, System.EventArgs e) { TrackTreeViewGroup group = Owner as TrackTreeViewGroup; _View.DeleteGroup(group); }
void AddTrack_Click(object sender, System.EventArgs e) { TrackTreeViewGroup group = Owner as TrackTreeViewGroup; _View.CreateTrack(group, (TrackType)((Skill.Editor.UI.MenuItem)sender).UserData); }
private void Refresh(Transform transform, Skill.Framework.UI.Panel panel) { List <TrackGroup> groupList = new List <TrackGroup>(); List <Track> trackList = new List <Track>(); int childCount = transform.childCount; // first check for any new group or track for (int childIndex = 0; childIndex < childCount; childIndex++) { Transform childT = transform.GetChild(childIndex); TrackGroup group = childT.GetComponent <TrackGroup>(); if (group != null && !group.IsDestroyed) { groupList.Add(group); TrackTreeViewGroup groupItem = null; foreach (var item in panel.Controls) { if (item is TrackTreeViewGroup) { if (((TrackTreeViewGroup)item).Group == group) { groupItem = (TrackTreeViewGroup)item; break; } } } if (groupItem == null) { groupItem = new TrackTreeViewGroup(group); groupItem.Foldout.Content.text = groupItem.Group.gameObject.name; groupItem.ContextMenu = _TrackGroupContextMenu; panel.Controls.Add(groupItem); } //else //groupItem.Refresh(); Refresh(groupItem.Group.transform, groupItem); continue; } // if group not exist look for track Track track = childT.GetComponent <Track>(); if (track != null && !track.IsDestroyed) { trackList.Add(track); TrackTreeViewItem trackItem = null; foreach (var item in panel.Controls) { if (item is TrackTreeViewItem) { if (((TrackTreeViewItem)item).Track == track) { trackItem = (TrackTreeViewItem)item; break; } } } if (trackItem == null) { BaseTrackBar bar = CreateNewTrackBar(track); _Editor.TimeLine.View.Controls.Add(bar); trackItem = new TrackTreeViewItem(track, bar); trackItem.ContextMenu = _TrackItemContextMenu; panel.Controls.Add(trackItem); } } } // now check for any deleted group or track int index = 0; while (index < panel.Controls.Count) { var item = panel.Controls[index]; if (item is TrackTreeViewGroup) { TrackGroup group = ((TrackTreeViewGroup)item).Group; if (!groupList.Contains(group)) { RemoveTracks((TrackTreeViewGroup)item); panel.Controls.Remove(item); continue; } } else if (item is TrackTreeViewItem) { Track track = ((TrackTreeViewItem)item).Track; if (!trackList.Contains(track)) { panel.Controls.Remove(item); _Editor.TimeLine.View.Controls.Remove(((TrackTreeViewItem)item).TrackBar); continue; } } index++; } foreach (var item in Controls) { if (item is TrackTreeViewItem) { ((TrackTreeViewItem)item).Refresh(); } } }