public static CinemaGlobalAction CreateGlobalAction(GlobalItemTrack track, Type type, string name, float firetime) { GameObject item = new GameObject(name); CinemaGlobalAction action = item.AddComponent(type) as CinemaGlobalAction; SortedDictionary <float, CinemaGlobalAction> sortedActions = new SortedDictionary <float, CinemaGlobalAction>(); foreach (CinemaGlobalAction a in track.Actions) { sortedActions.Add(a.Firetime, a); } float latestTime = firetime; float length = DEFAULT_GLOBAL_ACTION_LENGTH; foreach (CinemaGlobalAction a in sortedActions.Values) { if (latestTime >= a.Firetime) { latestTime = Mathf.Max(latestTime, a.Firetime + a.Duration); } else { length = a.Firetime - latestTime; break; } } action.Firetime = latestTime; action.Duration = length; item.transform.parent = track.transform; return(action); }
internal static CinemaGlobalEvent CreateGlobalEvent(GlobalItemTrack track, Type type, string name, float firetime) { GameObject item = new GameObject(name); item.transform.parent = track.transform; CinemaGlobalEvent globalEvent = item.AddComponent(type) as CinemaGlobalEvent; globalEvent.Firetime = firetime; return(globalEvent); }
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(); }
protected override void updateHeaderControl3(UnityEngine.Rect position) { GlobalItemTrack itemTrack = TargetTrack.Behaviour as GlobalItemTrack; if (itemTrack == null) { return; } Color temp = GUI.color; GUI.color = (itemTrack.TimelineItems.Length > 0) ? Color.green : Color.red; if (GUI.Button(position, string.Empty, TrackGroupControl.styles.addIcon)) { addNewGlobalItem(itemTrack); } GUI.color = temp; }
protected override void showBodyContextMenu(Event evt) { GlobalItemTrack itemTrack = TargetTrack.Behaviour as GlobalItemTrack; if (itemTrack == null) { return; } Behaviour b = DirectorCopyPaste.Peek(); PasteContext pasteContext = new PasteContext(evt.mousePosition, itemTrack); GenericMenu createMenu = new GenericMenu(); if (b != null && DirectorHelper.IsTrackItemValidForTrack(b, itemTrack)) { createMenu.AddItem(new GUIContent("Paste"), false, pasteItem, pasteContext); } else { createMenu.AddDisabledItem(new GUIContent("Paste")); } createMenu.ShowAsContext(); }
/// <summary> /// Update and Draw the inspector /// </summary> public override void OnInspectorGUI() { eventTrack.Update(); GlobalItemTrack track = base.serializedObject.targetObject as GlobalItemTrack; CinemaGlobalAction[] actions = track.Actions; CinemaGlobalEvent[] events = track.Events; if (actions.Length > 0 || events.Length > 0) { actionFoldout = EditorGUILayout.Foldout(actionFoldout, actionContent); if (actionFoldout) { EditorGUI.indentLevel++; for (int i = 0; i < actions.Length; i++) { EditorGUILayout.ObjectField(actions[i].name, actions[i], typeof(CinemaGlobalAction), true); } for (int i = 0; i < events.Length; i++) { EditorGUILayout.ObjectField(events[i].name, events[i], typeof(CinemaGlobalEvent), true); } EditorGUI.indentLevel--; } } if (GUILayout.Button(addActionContent)) { GenericMenu createMenu = new GenericMenu(); Type[] actionSubTypes = DirectorHelper.GetAllSubTypes(typeof(CinemaGlobalAction)); for (int i = 0; i < actionSubTypes.Length; i++) { string text = string.Empty; string category = string.Empty; string label = string.Empty; object[] attrs = actionSubTypes[i].GetCustomAttributes(typeof(CutsceneItemAttribute), true); for (int j = 0; j < attrs.Length; j++) { CutsceneItemAttribute attribute = attrs[j] as CutsceneItemAttribute; if (attribute != null) { category = attribute.Category; label = attribute.Label; text = string.Format("{0}/{1}", attribute.Category, attribute.Label); break; } } if (label != string.Empty) { ContextData userData = new ContextData { Type = actionSubTypes[i], Label = label, Category = category }; createMenu.AddItem(new GUIContent(text), false, new GenericMenu.MenuFunction2(AddEvent), userData); } } Type[] eventSubTypes = DirectorHelper.GetAllSubTypes(typeof(CinemaGlobalEvent)); for (int i = 0; i < eventSubTypes.Length; i++) { string text = string.Empty; string category = string.Empty; string label = string.Empty; object[] attrs = eventSubTypes[i].GetCustomAttributes(typeof(CutsceneItemAttribute), true); for (int j = 0; j < attrs.Length; j++) { CutsceneItemAttribute attribute = attrs[j] as CutsceneItemAttribute; if (attribute != null) { category = attribute.Category; label = attribute.Label; text = string.Format("{0}/{1}", attribute.Category, attribute.Label); break; } } if (label != string.Empty) { ContextData userData = new ContextData { Type = eventSubTypes[i], Label = label, Category = category }; createMenu.AddItem(new GUIContent(text), false, new GenericMenu.MenuFunction2(AddEvent), userData); } } createMenu.ShowAsContext(); } eventTrack.ApplyModifiedProperties(); }
/// <summary> /// Update and Draw the inspector /// </summary> public override void OnInspectorGUI() { eventTrack.Update(); GlobalItemTrack track = base.serializedObject.targetObject as GlobalItemTrack; CinemaGlobalAction[] actions = track.Actions; CinemaGlobalEvent[] events = track.Events; if (actions.Length > 0 || events.Length > 0) { actionFoldout = EditorGUILayout.Foldout(actionFoldout, actionContent); if (actionFoldout) { EditorGUI.indentLevel++; { var __array1 = actions; var __arrayLength1 = __array1.Length; for (int __i1 = 0; __i1 < __arrayLength1; ++__i1) { var action = (CinemaGlobalAction)__array1[__i1]; { EditorGUILayout.ObjectField(action.name, action, typeof(CinemaGlobalAction), true); } } } { var __array2 = events; var __arrayLength2 = __array2.Length; for (int __i2 = 0; __i2 < __arrayLength2; ++__i2) { var globalEvent = (CinemaGlobalEvent)__array2[__i2]; { EditorGUILayout.ObjectField(globalEvent.name, globalEvent, typeof(CinemaGlobalEvent), true); } } } EditorGUI.indentLevel--; } } if (GUILayout.Button(addActionContent)) { GenericMenu createMenu = new GenericMenu(); { // foreach(var type in DirectorHelper.GetAllSubTypes(typeof(CinemaGlobalAction))) var __enumerator3 = (DirectorHelper.GetAllSubTypes(typeof(CinemaGlobalAction))).GetEnumerator(); while (__enumerator3.MoveNext()) { var type = (Type)__enumerator3.Current; { string text = string.Empty; string category = string.Empty; string label = string.Empty; { var __array5 = type.GetCustomAttributes(typeof(CutsceneItemAttribute), true); var __arrayLength5 = __array5.Length; for (int __i5 = 0; __i5 < __arrayLength5; ++__i5) { var attribute = (CutsceneItemAttribute)__array5[__i5]; { if (attribute != null) { category = attribute.Category; label = attribute.Label; text = string.Format("{0}/{1}", attribute.Category, attribute.Label); break; } } } } if (label != string.Empty) { ContextData userData = new ContextData { Type = type, Label = label, Category = category }; createMenu.AddItem(new GUIContent(text), false, new GenericMenu.MenuFunction2(AddEvent), userData); } } } } { // foreach(var type in DirectorHelper.GetAllSubTypes(typeof(CinemaGlobalEvent))) var __enumerator4 = (DirectorHelper.GetAllSubTypes(typeof(CinemaGlobalEvent))).GetEnumerator(); while (__enumerator4.MoveNext()) { var type = (Type)__enumerator4.Current; { string text = string.Empty; string category = string.Empty; string label = string.Empty; { var __array6 = type.GetCustomAttributes(typeof(CutsceneItemAttribute), true); var __arrayLength6 = __array6.Length; for (int __i6 = 0; __i6 < __arrayLength6; ++__i6) { var attribute = (CutsceneItemAttribute)__array6[__i6]; { if (attribute != null) { category = attribute.Category; label = attribute.Label; text = string.Format("{0}/{1}", attribute.Category, attribute.Label); break; } } } } if (label != string.Empty) { ContextData userData = new ContextData { Type = type, Label = label, Category = category }; createMenu.AddItem(new GUIContent(text), false, new GenericMenu.MenuFunction2(AddEvent), userData); } } } } createMenu.ShowAsContext(); } eventTrack.ApplyModifiedProperties(); }
public PasteContext(Vector2 mousePosition, GlobalItemTrack track) { this.mousePosition = mousePosition; this.track = track; }