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(); }
/// <summary> /// Show the "Add Track Group" context menu. /// </summary> /// <param name="cutscene">The current Cutscene that the track group will be added to.</param> public static void ShowAddTrackGroupContextMenu(Cutscene cutscene) { GenericMenu createMenu = new GenericMenu(); foreach (Type type in DirectorHelper.GetAllSubTypes(typeof(TrackGroup))) { TrackGroupContextData userData = getContextDataFromType(cutscene, type); string text = string.Format(userData.Label); createMenu.AddItem(new GUIContent(text), false, new GenericMenu.MenuFunction2(AddTrackGroup), userData); } createMenu.ShowAsContext(); }
/// <summary> /// Show the "Add Track Group" context menu. /// </summary> /// <param name="cutscene">The current Cutscene that the track group will be added to.</param> public static void ShowAddTrackGroupContextMenu(TimelineManager cutscene) { GenericMenu createMenu = new GenericMenu(); Type[] subTypes = DirectorHelper.GetAllSubTypes(typeof(TrackGroup)); for (int i = 0; i < subTypes.Length; i++) { TrackGroupContextData userData = getContextDataFromType(cutscene, subTypes[i]); string text = string.Format(userData.Label); createMenu.AddItem(new GUIContent(text), false, new GenericMenu.MenuFunction2(AddTrackGroup), userData); } createMenu.ShowAsContext(); }
/// <summary> /// Show the "Add Track Group" context menu. /// </summary> /// <param name="cutscene">The current Cutscene that the track group will be added to.</param> public static void ShowAddTrackGroupContextMenu(Cutscene cutscene) { GenericMenu createMenu = new GenericMenu(); { // foreach(var type in DirectorHelper.GetAllSubTypes(typeof(TrackGroup))) var __enumerator1 = (DirectorHelper.GetAllSubTypes(typeof(TrackGroup))).GetEnumerator(); while (__enumerator1.MoveNext()) { var type = (Type)__enumerator1.Current; { TrackGroupContextData userData = getContextDataFromType(cutscene, type); string text = string.Format(userData.Label); createMenu.AddItem(new GUIContent(text), false, new GenericMenu.MenuFunction2(AddTrackGroup), userData); } } } createMenu.ShowAsContext(); }
private void addNewActorItem(ActorItemTrack itemTrack) { GenericMenu createMenu = new GenericMenu(); Type actorActionType = typeof(CinemaActorAction); foreach (Type type in DirectorHelper.GetAllSubTypes(actorActionType)) { ContextData userData = getContextDataFromType(type); string text = string.Format("{0}/{1}", userData.Category, userData.Label); createMenu.AddItem(new GUIContent(text), false, new GenericMenu.MenuFunction2(AddActorAction), userData); } Type actorEventType = typeof(CinemaActorEvent); foreach (Type type in DirectorHelper.GetAllSubTypes(actorEventType)) { ContextData userData = getContextDataFromType(type); string text = string.Format("{0}/{1}", userData.Category, userData.Label); createMenu.AddItem(new GUIContent(text), false, new GenericMenu.MenuFunction2(AddActorEvent), userData); } createMenu.ShowAsContext(); }
/// <summary> /// Update and Draw the inspector /// </summary> public override void OnInspectorGUI() { eventTrack.Update(); ActorItemTrack track = base.serializedObject.targetObject as ActorItemTrack; CinemaActorAction[] actions = track.ActorActions; CinemaActorEvent[] actorEvents = track.ActorEvents; if (actions.Length > 0 || actorEvents.Length > 0) { actionFoldout = EditorGUILayout.Foldout(actionFoldout, actionContent); if (actionFoldout) { EditorGUI.indentLevel++; foreach (CinemaActorAction action in actions) { EditorGUILayout.ObjectField(action.name, action, typeof(CinemaActorAction), true); } foreach (CinemaActorEvent actorEvent in actorEvents) { EditorGUILayout.ObjectField(actorEvent.name, actorEvent, typeof(CinemaActorEvent), true); } EditorGUI.indentLevel--; } } if (GUILayout.Button(addActionContent)) { GenericMenu createMenu = new GenericMenu(); Type actorActionType = typeof(CinemaActorAction); foreach (Type type in DirectorHelper.GetAllSubTypes(actorActionType)) { 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}", category, label); break; } } ContextData userData = new ContextData { type = type, label = label, category = category }; createMenu.AddItem(new GUIContent(text), false, new GenericMenu.MenuFunction2(AddEvent), userData); } Type actorEventType = typeof(CinemaActorEvent); foreach (Type type in DirectorHelper.GetAllSubTypes(actorEventType)) { 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; } } 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(); }
/// <summary> /// Draw and update the toolbar for the director control /// </summary> /// <param name="toolbarArea">The area for the toolbar</param> private void updateToolbar(Rect toolbarArea) { EditorGUILayout.BeginHorizontal(EditorStyles.toolbar); // If there are no cutscenes, then only give option to create a new cutscene. if (GUILayout.Button(CREATE, EditorStyles.toolbarDropDown, GUILayout.Width(60))) { GenericMenu createMenu = new GenericMenu(); createMenu.AddItem(new_cutscene, false, openCutsceneCreatorWindow); createMenu.AddItem(default_cutscene, false, createDefaultCutscene); createMenu.AddItem(empty_cutscene, false, createEmptyCutscene); if (cutscene != null) { createMenu.AddSeparator(string.Empty); createMenu.AddItem(new_cutscene_trigger, false, createCutsceneTrigger); createMenu.AddSeparator(string.Empty); Type[] subTypes = DirectorHelper.GetAllSubTypes(typeof(TrackGroup)); for (int i = 0; i < subTypes.Length; i++) { TrackGroupContextData userData = getContextDataFromType(subTypes[i]); string text = string.Format(userData.Label); createMenu.AddItem(new GUIContent(text), false, new GenericMenu.MenuFunction2(AddTrackGroup), userData); } } createMenu.DropDown(new Rect(5, TOOLBAR_HEIGHT, 0, 0)); } // Cutscene selector cachedCutscenes = GameObject.FindObjectsOfType <Cutscene>(); if (cachedCutscenes != null && cachedCutscenes.Length > 0) { // Get cutscene names GUIContent[] cutsceneNames = new GUIContent[cachedCutscenes.Length]; for (int i = 0; i < cachedCutscenes.Length; i++) { cutsceneNames[i] = new GUIContent(cachedCutscenes[i].name); } // Sort alphabetically Array.Sort(cutsceneNames, delegate(GUIContent content1, GUIContent content2) { return(string.Compare(content1.text, content2.text)); }); int count = 1; // Resolve duplicate names for (int i = 0; i < cutsceneNames.Length - 1; i++) { int next = i + 1; while (next < cutsceneNames.Length && string.Compare(cutsceneNames[i].text, cutsceneNames[next].text) == 0) { cutsceneNames[next].text = string.Format("{0} (duplicate {1})", cutsceneNames[next].text, count++); next++; } count = 1; } Array.Sort(cachedCutscenes, delegate(Cutscene c1, Cutscene c2) { return(string.Compare(c1.name, c2.name)); }); // Find the currently selected cutscene. for (int i = 0; i < cachedCutscenes.Length; i++) { if (cutscene != null && cutscene.GetInstanceID() == cachedCutscenes[i].GetInstanceID()) { popupSelection = i; } } // Show the popup int tempPopup = EditorGUILayout.Popup(popupSelection, cutsceneNames, EditorStyles.toolbarPopup); if (cutscene == null || tempPopup != popupSelection || cutsceneInstanceID != cachedCutscenes[Math.Min(tempPopup, cachedCutscenes.Length - 1)].GetInstanceID()) { popupSelection = tempPopup; popupSelection = Math.Min(popupSelection, cachedCutscenes.Length - 1); FocusCutscene(cachedCutscenes[popupSelection]); } } if (cutscene != null) { if (GUILayout.Button(pickerImage, EditorStyles.toolbarButton, GUILayout.Width(24))) { Selection.activeObject = cutscene; } if (GUILayout.Button(refreshImage, EditorStyles.toolbarButton, GUILayout.Width(24))) { cutscene.Refresh(); } if (Event.current.control && Event.current.keyCode == KeyCode.Space) { cutscene.Refresh(); Event.current.Use(); } } GUILayout.FlexibleSpace(); if (betaFeaturesEnabled) { Texture resizeTexture = cropImage; if (directorControl.ResizeOption == DirectorEditor.ResizeOption.Scale) { resizeTexture = scaleImage; } Rect resizeRect = GUILayoutUtility.GetRect(new GUIContent(resizeTexture), EditorStyles.toolbarDropDown, GUILayout.Width(32)); if (GUI.Button(resizeRect, new GUIContent(resizeTexture, "Resize Option"), EditorStyles.toolbarDropDown)) { GenericMenu resizeMenu = new GenericMenu(); string[] names = Enum.GetNames(typeof(DirectorEditor.ResizeOption)); for (int i = 0; i < names.Length; i++) { resizeMenu.AddItem(new GUIContent(names[i]), directorControl.ResizeOption == (DirectorEditor.ResizeOption)i, chooseResizeOption, i); } resizeMenu.DropDown(new Rect(resizeRect.x, TOOLBAR_HEIGHT, 0, 0)); } } bool tempSnapping = GUILayout.Toggle(isSnappingEnabled, snapImage, EditorStyles.toolbarButton, GUILayout.Width(24)); if (tempSnapping != isSnappingEnabled) { isSnappingEnabled = tempSnapping; directorControl.IsSnappingEnabled = isSnappingEnabled; } //GUILayout.Button(rollingEditImage, EditorStyles.toolbarButton, GUILayout.Width(24)); GUILayout.Space(10f); if (GUILayout.Button(rescaleImage, EditorStyles.toolbarButton, GUILayout.Width(24))) { directorControl.Rescale(); } if (GUILayout.Button(new GUIContent(zoomInImage, "Zoom In"), EditorStyles.toolbarButton, GUILayout.Width(24))) { directorControl.ZoomIn(); } if (GUILayout.Button(zoomOutImage, EditorStyles.toolbarButton, GUILayout.Width(24))) { directorControl.ZoomOut(); } GUILayout.Space(10f); Color temp = GUI.color; GUI.color = directorControl.InPreviewMode ? Color.red : temp; directorControl.InPreviewMode = GUILayout.Toggle(directorControl.InPreviewMode, PREVIEW_MODE, EditorStyles.toolbarButton, GUILayout.Width(150)); GUI.color = temp; GUILayout.Space(10); if (GUILayout.Button(settingsImage, EditorStyles.toolbarButton, GUILayout.Width(30))) { EditorWindow.GetWindow <DirectorSettingsWindow>(); } // Check if the Welcome Window exists and if so, show an icon for it. var helpWindowType = Type.GetType("CinemaSuite.CinemaSuiteWelcome"); if (helpWindowType != null) { if (GUILayout.Button(new GUIContent("?", "Help"), EditorStyles.toolbarButton)) { EditorWindow.GetWindow(helpWindowType); } } EditorGUILayout.EndHorizontal(); }
/// <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> /// Draw and update the toolbar for the director control /// </summary> /// <param name="toolbarArea">The area for the toolbar</param> private void updateToolbar(Rect toolbarArea) { EditorGUILayout.BeginHorizontal(EditorStyles.toolbar); // If there are no cutscenes, then only give option to create a new cutscene. if (GUILayout.Button(CREATE, EditorStyles.toolbarDropDown, GUILayout.Width(60))) { GenericMenu createMenu = new GenericMenu(); createMenu.AddItem(new_cutscene, false, openCutsceneCreatorWindow); if (cutscene != null) { createMenu.AddSeparator(string.Empty); foreach (Type type in DirectorHelper.GetAllSubTypes(typeof(TrackGroup))) { TrackGroupContextData userData = getContextDataFromType(type); string text = string.Format(userData.Label); createMenu.AddItem(new GUIContent(text), false, new GenericMenu.MenuFunction2(AddTrackGroup), userData); } } createMenu.DropDown(new Rect(5, TOOLBAR_HEIGHT, 0, 0)); } // Cutscene selector cachedCutscenes = GameObject.FindObjectsOfType <Cutscene>(); if (cachedCutscenes != null && cachedCutscenes.Length > 0) { // Get cutscene names GUIContent[] cutsceneNames = new GUIContent[cachedCutscenes.Length]; for (int i = 0; i < cachedCutscenes.Length; i++) { cutsceneNames[i] = new GUIContent(cachedCutscenes[i].name); } // Sort alphabetically Array.Sort(cutsceneNames, delegate(GUIContent content1, GUIContent content2) { return(string.Compare(content1.text, content2.text)); }); Array.Sort(cachedCutscenes, delegate(Cutscene c1, Cutscene c2) { return(string.Compare(c1.name, c2.name)); }); // Find the currently selected cutscene. for (int i = 0; i < cachedCutscenes.Length; i++) { if (cutscene != null && cutscene.GetInstanceID() == cachedCutscenes[i].GetInstanceID()) { popupSelection = i; } } // Show the popup int tempPopup = EditorGUILayout.Popup(popupSelection, cutsceneNames, EditorStyles.toolbarPopup); if (tempPopup != popupSelection) { popupSelection = tempPopup; EditorPrefs.SetInt("DirectorControl.CutsceneID", cachedCutscenes[popupSelection].GetInstanceID()); } popupSelection = Math.Min(popupSelection, cachedCutscenes.Length - 1); cutscene = cachedCutscenes[popupSelection]; } if (cutscene != null) { if (GUILayout.Button(pickerImage, EditorStyles.toolbarButton, GUILayout.Width(24))) { Selection.activeObject = cutscene; } if (GUILayout.Button(refreshImage, EditorStyles.toolbarButton, GUILayout.Width(24))) { cutscene.Refresh(); } if (Event.current.control && Event.current.keyCode == KeyCode.Space) { cutscene.Refresh(); Event.current.Use(); } } GUILayout.FlexibleSpace(); bool tempSnapping = GUILayout.Toggle(isSnappingEnabled, snapImage, EditorStyles.toolbarButton, GUILayout.Width(24)); if (tempSnapping != isSnappingEnabled) { isSnappingEnabled = tempSnapping; directorControl.IsSnappingEnabled = isSnappingEnabled; } GUILayout.Button(rippleEditImage, EditorStyles.toolbarButton, GUILayout.Width(24)); GUILayout.Button(rollingEditImage, EditorStyles.toolbarButton, GUILayout.Width(24)); GUILayout.Space(10f); if (GUILayout.Button(rescaleImage, EditorStyles.toolbarButton, GUILayout.Width(24))) { directorControl.Rescale(); } if (GUILayout.Button(new GUIContent(zoomInImage, "Zoom In"), EditorStyles.toolbarButton, GUILayout.Width(24))) { directorControl.ZoomIn(); } if (GUILayout.Button(zoomOutImage, EditorStyles.toolbarButton, GUILayout.Width(24))) { directorControl.ZoomOut(); } GUILayout.Space(10f); Color temp = GUI.color; GUI.color = directorControl.InPreviewMode ? Color.red : temp; directorControl.InPreviewMode = GUILayout.Toggle(directorControl.InPreviewMode, PREVIEW_MODE, EditorStyles.toolbarButton, GUILayout.Width(150)); GUI.color = temp; GUILayout.Space(10); if (GUILayout.Button("?", EditorStyles.toolbarButton)) { EditorWindow.GetWindow <DirectorHelpWindow>(); } EditorGUILayout.EndHorizontal(); }
/// <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(); }