private void addNewGlobalItem(GlobalItemTrack itemTrack) { GenericMenu createMenu = new GenericMenu(); foreach (Type type in DirectorHelper.GetAllSubTypes(typeof(CinemaGlobalAction))) { string text = string.Empty; string category = string.Empty; string label = string.Empty; foreach (CutsceneItemAttribute attribute in type.GetCustomAttributes(typeof(CutsceneItemAttribute), true)) { if (attribute != null) { category = attribute.Category; label = attribute.Label; text = string.Format("{0}/{1}", attribute.Category, attribute.Label); break; } } if (label != string.Empty) { TrackItemInfoContextData userData = new TrackItemInfoContextData { Type = type, Label = label, Category = category }; createMenu.AddItem(new GUIContent(text), false, new GenericMenu.MenuFunction2(AddGlobalAction), userData); } } foreach (Type type in DirectorHelper.GetAllSubTypes(typeof(CinemaGlobalEvent))) { string text = string.Empty; string category = string.Empty; string label = string.Empty; foreach (CutsceneItemAttribute attribute in type.GetCustomAttributes(typeof(CutsceneItemAttribute), true)) { if (attribute != null) { category = attribute.Category; label = attribute.Label; text = string.Format("{0}/{1}", attribute.Category, attribute.Label); break; } } if (label != string.Empty) { TrackItemInfoContextData userData = new TrackItemInfoContextData { Type = type, Label = label, Category = category }; createMenu.AddItem(new GUIContent(text), false, new GenericMenu.MenuFunction2(AddGlobalEvent), userData); } } createMenu.ShowAsContext(); }
private void AddGlobalEvent(object userData) { TrackItemInfoContextData data = userData as TrackItemInfoContextData; if (data != null) { string name = DirectorHelper.getCutsceneItemName(data.Label, data.Type); float firetime = state.IsInPreviewMode ? state.ScrubberPosition : 0f; GameObject item = CutsceneItemFactory.CreateGlobalEvent((TargetTrack.Behaviour as GlobalItemTrack), data.Type, name, firetime).gameObject; Undo.RegisterCreatedObjectUndo(item, string.Format("Created {0}", item.name)); } }