/// <summary> /// Draws the Director GUI /// </summary> protected void OnGUI() { scrollPosition = EditorGUILayout.BeginScrollView(scrollPosition); { txtCutsceneName = EditorGUILayout.TextField(NameContentCutscene, txtCutsceneName); EditorGUILayout.BeginHorizontal(); txtDuration = EditorGUILayout.FloatField(DurationContentCutscene, txtDuration); timeEnum = (DirectorHelper.TimeEnum)EditorGUILayout.EnumPopup(timeEnum); EditorGUILayout.EndHorizontal(); isLooping = EditorGUILayout.Toggle(LoopingContentCutscene, isLooping); isSkippable = EditorGUILayout.Toggle(SkippableContentCutscene, isSkippable); StartMethod = (StartMethod)EditorGUILayout.EnumPopup(new GUIContent("开始方法"), StartMethod); EditorGUILayout.Space(); EditorGUILayout.LabelField("轨道组", EditorStyles.boldLabel); // Director Group directorTrackGroupsSelection = EditorGUILayout.Popup(AddDirectorGroupContent, directorTrackGroupsSelection, intValues1.ToArray()); if (directorTrackGroupsSelection > 0) { EditorGUI.indentLevel++; // Shot Tracks shotTrackSelection = EditorGUILayout.Popup(AddShotTracksContent, shotTrackSelection, intValues1.ToArray()); // Audio Tracks audioTrackSelection = EditorGUILayout.Popup(AddAudioTracksContent, audioTrackSelection, intValues4.ToArray()); // Global Item Tracks globalItemTrackSelection = EditorGUILayout.Popup(AddGlobalTracksContent, globalItemTrackSelection, intValues10.ToArray()); EditorGUI.indentLevel--; } EditorGUILayout.Space(); // Actor Track Groups int actorCount = EditorGUILayout.Popup(new GUIContent("主角轨道群组"), actorTrackGroupsSelection, intValues10.ToArray()); if (actorCount != actorTrackGroupsSelection) { actorTrackGroupsSelection = actorCount; Transform[] tempActors = new Transform[actors.Length]; Array.Copy(actors, tempActors, actors.Length); actors = new Transform[actorCount]; int amount = Math.Min(actorCount, tempActors.Length); Array.Copy(tempActors, actors, amount); } EditorGUI.indentLevel++; for (int i = 1; i <= actorTrackGroupsSelection; i++) { actors[i - 1] = EditorGUILayout.ObjectField(new GUIContent(string.Format("主角 {0}", i)), actors[i - 1], typeof(Transform), true) as Transform; } EditorGUI.indentLevel--; EditorGUILayout.Space(); // Multi Actor Track Groups multiActorTrackGroupsSelection = EditorGUILayout.Popup(new GUIContent("多主角轨道群组"), multiActorTrackGroupsSelection, intValues10.ToArray()); EditorGUI.indentLevel++; EditorGUI.indentLevel--; Add(ref characters, ref characterTrackGroupsSelection, "ActorTrackGroups"); for (int i = 1; i <= characterTrackGroupsSelection; i++) { characters[i - 1] = EditorGUILayout.ObjectField(new GUIContent(string.Format("角色 {0}", i)), characters[i - 1], typeof(Transform), true) as Transform; } EditorGUI.indentLevel--; } EditorGUILayout.EndScrollView(); EditorGUILayout.BeginHorizontal(); { if (GUILayout.Button("I'm Feeling Lucky")) { List <Transform> interestingActors = UnitySceneEvaluator.GetHighestRankedGameObjects(10); actorTrackGroupsSelection = interestingActors.Count; actors = interestingActors.ToArray(); } if (GUILayout.Button("创建剧情")) { string cutsceneName = DirectorHelper.getCutsceneItemName(txtCutsceneName, typeof(Cutscene)); GameObject cutsceneGO = new GameObject(cutsceneName); Cutscene cutscene = cutsceneGO.AddComponent <Cutscene>(); for (int i = 0; i < directorTrackGroupsSelection; i++) { DirectorGroup dg = CutsceneItemFactory.CreateDirectorGroup(cutscene); dg.Ordinal = 0; for (int j = 0; j < shotTrackSelection; j++) { CutsceneItemFactory.CreateShotTrack(dg); } for (int j = 0; j < audioTrackSelection; j++) { CutsceneItemFactory.CreateAudioTrack(dg); } for (int j = 0; j < globalItemTrackSelection; j++) { CutsceneItemFactory.CreateGlobalItemTrack(dg); } } for (int i = 0; i < actorTrackGroupsSelection; i++) { CutsceneItemFactory.CreateActorTrackGroup(cutscene, actors[i]); } for (int i = 0; i < multiActorTrackGroupsSelection; i++) { CutsceneItemFactory.CreateMultiActorTrackGroup(cutscene); } for (int i = 0; i < characterTrackGroupsSelection; i++) { CutsceneItemFactory.CreateCharacterTrackGroup(cutscene, characters[i]); } float duration = txtDuration; if (timeEnum == DirectorHelper.TimeEnum.Minutes) { duration *= 60; } cutscene.Duration = duration; int undoIndex = Undo.GetCurrentGroup(); if (StartMethod != StartMethod.None) { GameObject cutsceneTriggerGO = new GameObject("Cutscene Trigger"); CutsceneTrigger cutsceneTrigger = cutsceneTriggerGO.AddComponent <CutsceneTrigger>(); if (StartMethod == StartMethod.OnTrigger) { cutsceneTriggerGO.AddComponent <BoxCollider>(); } cutsceneTrigger.StartMethod = StartMethod; cutsceneTrigger.Cutscene = cutscene; Undo.RegisterCreatedObjectUndo(cutsceneTriggerGO, string.Format("Created {0}", txtCutsceneName)); } Undo.RegisterCreatedObjectUndo(cutsceneGO, string.Format("Created {0}", txtCutsceneName)); Undo.CollapseUndoOperations(undoIndex); Selection.activeTransform = cutsceneGO.transform; } } EditorGUILayout.EndHorizontal(); }
/// <summary> /// Add an empty multi actor group to the current cutscene. /// </summary> private void addMultiActorGroup() { Undo.RegisterCreatedObjectUndo(CutsceneItemFactory.CreateMultiActorTrackGroup(cutscene).gameObject, "Create Multi-Actor Group"); }
public Cutscene CreateCutscene() { string cutsceneName = DirectorHelper.getCutsceneItemName(txtCutsceneName, typeof(Cutscene)); GameObject cutsceneGO = new GameObject(cutsceneName); Cutscene cutscene = cutsceneGO.AddComponent <Cutscene>(); for (int i = 0; i < directorTrackGroupsSelection; i++) { DirectorGroup dg = CutsceneItemFactory.CreateDirectorGroup(cutscene); dg.Ordinal = 0; for (int j = 0; j < shotTrackSelection; j++) { CutsceneItemFactory.CreateShotTrack(dg); } for (int j = 0; j < audioTrackSelection; j++) { CutsceneItemFactory.CreateAudioTrack(dg); } for (int j = 0; j < globalItemTrackSelection; j++) { CutsceneItemFactory.CreateGlobalItemTrack(dg); } } for (int i = 0; i < actorTrackGroupsSelection; i++) { CutsceneItemFactory.CreateActorTrackGroup(cutscene, actors[i]); } for (int i = 0; i < multiActorTrackGroupsSelection; i++) { CutsceneItemFactory.CreateMultiActorTrackGroup(cutscene); } for (int i = 0; i < characterTrackGroupsSelection; i++) { CutsceneItemFactory.CreateCharacterTrackGroup(cutscene, characters[i]); } float duration = txtDuration; if (timeEnum == DirectorHelper.TimeEnum.Minutes) { duration *= 60; } cutscene.Duration = duration; cutscene.IsLooping = isLooping; cutscene.IsSkippable = isSkippable; int undoIndex = Undo.GetCurrentGroup(); if (StartMethod != StartMethod.None) { CreateCutsceneTrigger(cutscene); } Undo.RegisterCreatedObjectUndo(cutsceneGO, string.Format("Created {0}", txtCutsceneName)); Undo.CollapseUndoOperations(undoIndex); Selection.activeTransform = cutsceneGO.transform; return(cutscene); }
internal void addMultiActorGroup() { Cutscene c = base.serializedObject.targetObject as Cutscene; CutsceneItemFactory.CreateMultiActorTrackGroup(c); }