/// <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(); }
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); }
/// <summary> /// Add an empty actor group to the current cutscene. /// </summary> private void addActorGroup() { Undo.RegisterCreatedObjectUndo(CutsceneItemFactory.CreateActorTrackGroup(cutscene).gameObject, "Create Actor Group"); }
public static void CreateCutscene(List <Sequence.FrameInfo> Frames, float DurationPerFrame) { string cutsceneName = DirectorHelper.getCutsceneItemName("New Cutscene", typeof(Cutscene)); GameObject cutsceneGO = new GameObject(cutsceneName); Cutscene cutscene = cutsceneGO.AddComponent <Cutscene>(); GameObject framesGO = new GameObject("Frames"); framesGO.transform.SetParent(cutsceneGO.transform); GameObject triggersGO = new GameObject("Triggers"); triggersGO.transform.SetParent(cutsceneGO.transform); List <Transform> frameTransforms = new List <Transform>(); float time = 0; for (int i = 0; i < Frames.Count; i++) { if (Frames[i].m_Source == null) { time += DurationPerFrame * Frames[i].Duration; continue; } var frameGO = GameObject.Instantiate(Frames[i].m_Source) as GameObject; frameGO.name = Frames[i].m_Source.name; frameGO.transform.SetParent(framesGO.transform); frameGO.transform.localPosition = Vector3.zero; frameGO.transform.localEulerAngles = Vector3.zero; frameGO.transform.localScale = Vector3.one; frameGO.SetActive(false); frameTransforms.Add(frameGO.transform); var group = CutsceneItemFactory.CreateActorTrackGroup(cutscene, frameGO.transform) as ActorTrackGroup; group.transform.SetParent(triggersGO.transform); var track = CutsceneItemFactory.CreateActorItemTrack(group); var action = CutsceneItemFactory.CreateActorAction(track, typeof(EnableGameObjectAction), "Temporary Enable", time) as EnableGameObjectAction; action.Firetime = time; action.Duration = DurationPerFrame * Frames[i].Duration; time += action.Duration; CutsceneItemFactory.CreateActorEvent(track, typeof(DisableGameObject), "Disable", 0); } cutscene.Duration = time; cutscene.IsLooping = true; cutscene.IsSkippable = false; // Cutscene trigger GameObject cutsceneTriggerGO = new GameObject("Cutscene Trigger"); cutsceneTriggerGO.transform.SetParent(cutsceneGO.transform); CutsceneTrigger cutsceneTrigger = cutsceneTriggerGO.AddComponent <CutsceneTrigger>(); cutsceneTrigger.StartMethod = StartMethod.OnStart; cutsceneTrigger.Cutscene = cutscene; int undoIndex = Undo.GetCurrentGroup(); Undo.RegisterCreatedObjectUndo(cutsceneGO, "Created New Cutscene"); Undo.CollapseUndoOperations(undoIndex); Selection.activeTransform = cutsceneGO.transform; // Open director DirectorWindow window = EditorWindow.GetWindow(typeof(DirectorWindow)) as DirectorWindow; window.FocusCutscene(cutscene); }
internal void addActorGroup() { Cutscene c = base.serializedObject.targetObject as Cutscene; CutsceneItemFactory.CreateActorTrackGroup(c); }