示例#1
0
    public TimelineManager CreateCutscene()
    {
        string cutsceneName = DirectorHelper.getCutsceneItemName(txtCutsceneName, typeof(TimelineManager));

        GameObject      cutsceneGO = new GameObject(cutsceneName);
        TimelineManager cutscene   = cutsceneGO.AddComponent <TimelineManager>();

        cutsceneGO.AddComponent <Skill>();

        float duration = txtDuration;

        if (timeEnum == DirectorHelper.TimeEnum.Minutes)
        {
            duration *= 60;
        }
        cutscene.Duration = duration;

        cutscene.IsLooping = isLooping;

        cutscene.IsSkippable = isSkippable;

        int undoIndex = Undo.GetCurrentGroup();

        Undo.RegisterCreatedObjectUndo(cutsceneGO, string.Format("Created {0}", txtCutsceneName));
        Undo.CollapseUndoOperations(undoIndex);

        Selection.activeTransform = cutsceneGO.transform;

        return(cutscene);
    }
示例#2
0
    internal static GlobalItemTrack CreateGlobalItemTrack(DirectorGroup directorGroup)
    {
        string     name          = DirectorHelper.getCutsceneItemName(directorGroup.gameObject, GLOBAL_TRACK_LABEL, typeof(GlobalItemTrack));
        GameObject globalTrackGO = new GameObject(name, typeof(GlobalItemTrack));

        globalTrackGO.transform.parent = directorGroup.transform;
        return(globalTrackGO.GetComponent <GlobalItemTrack>());
    }
示例#3
0
    internal static AudioTrack CreateAudioTrack(DirectorGroup directorGroup)
    {
        string     name         = DirectorHelper.getCutsceneItemName(directorGroup.gameObject, AUDIO_TRACK_LABEL, typeof(AudioTrack));
        GameObject audioTrackGO = new GameObject(name, typeof(AudioTrack));

        audioTrackGO.transform.parent = directorGroup.transform;
        return(audioTrackGO.GetComponent <AudioTrack>());
    }
    private void AddActorAction(object userData)
    {
        ContextData data = userData as ContextData;

        if (data != null)
        {
            string name = DirectorHelper.getCutsceneItemName(data.Label, data.Type);

            GameObject item = CutsceneItemFactory.CreateActorAction((TargetTrack.Behaviour as ActorItemTrack), data.Type, name, state.ScrubberPosition).gameObject;
            Undo.RegisterCreatedObjectUndo(item, string.Format("Created {0}", item.name));
        }
    }
示例#5
0
    private void AddEvent(object userData)
    {
        ContextData data = userData as ContextData;

        if (data != null)
        {
            string     name       = DirectorHelper.getCutsceneItemName(data.Label, data.Type);
            GameObject trackEvent = new GameObject(name);
            trackEvent.AddComponent(data.Type);
            trackEvent.transform.parent = (this.target as GlobalItemTrack).transform;
        }
    }
    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));
        }
    }
示例#7
0
    /// <summary>
    /// Update and Draw the inspector
    /// </summary>
    public override void OnInspectorGUI()
    {
        audioTrack.Update();

        foreach (CinemaAudio audio in (target as AudioTrack).AudioClips)
        {
            EditorGUILayout.ObjectField(audio.name, audio, typeof(CinemaAudio), true);
        }

        if (GUILayout.Button(addAudio))
        {
            string     label     = DirectorHelper.getCutsceneItemName("Audio Item", typeof(CinemaAudio));
            GameObject audioItem = new GameObject(label, new System.Type[] { typeof(CinemaAudio), typeof(AudioSource) });
            audioItem.transform.parent = (this.target as AudioTrack).transform;
        }

        audioTrack.ApplyModifiedProperties();
    }
示例#8
0
    internal static CinemaAudio CreateCinemaAudio(AudioTrack track, AudioClip clip, float firetime)
    {
        string      name        = DirectorHelper.getCutsceneItemName(track.gameObject, AUDIO_CLIP_NAME_DEFAULT, typeof(CinemaAudio));
        GameObject  item        = new GameObject(name);
        CinemaAudio cinemaAudio = item.AddComponent <CinemaAudio>();
        AudioSource source      = item.AddComponent <AudioSource>();

        source.clip = clip;

        SortedDictionary <float, CinemaAudio> sortedClips = new SortedDictionary <float, CinemaAudio>();

        foreach (CinemaAudio a in track.AudioClips)
        {
            sortedClips.Add(a.Firetime, a);
        }

        float latestTime = firetime;

        float length = source.clip.length;

        foreach (CinemaAudio a in sortedClips.Values)
        {
            if (!(latestTime < a.Firetime && latestTime + length <= a.Firetime))
            {
                latestTime = a.Firetime + a.Duration;
            }
        }

        cinemaAudio.Firetime   = latestTime;
        cinemaAudio.Duration   = length;
        cinemaAudio.InTime     = 0;
        cinemaAudio.OutTime    = length;
        cinemaAudio.ItemLength = length;
        source.playOnAwake     = false;
        item.transform.parent  = track.transform;

        return(cinemaAudio);
    }
示例#9
0
    /// <summary>
    /// Update and Draw the inspector
    /// </summary>
    public override void OnInspectorGUI()
    {
        audioTrack.Update();
        {
            var __array1       = (target as AudioTrack).AudioClips;
            var __arrayLength1 = __array1.Length;
            for (int __i1 = 0; __i1 < __arrayLength1; ++__i1)
            {
                var audio = (CinemaAudio)__array1[__i1];
                {
                    EditorGUILayout.ObjectField(audio.name, audio, typeof(CinemaAudio), true);
                }
            }
        }
        if (GUILayout.Button(addAudio))
        {
            string     label     = DirectorHelper.getCutsceneItemName("Audio Item", typeof(CinemaAudio));
            GameObject audioItem = new GameObject(label, new System.Type[] { typeof(CinemaAudio), typeof(AudioSource) });
            audioItem.transform.parent = (this.target as AudioTrack).transform;
        }

        audioTrack.ApplyModifiedProperties();
    }
示例#10
0
    public static CinemaShot CreateNewShot(ShotTrack shotTrack)
    {
        string     name   = DirectorHelper.getCutsceneItemName(shotTrack.gameObject, SHOT_NAME_DEFAULT, typeof(CinemaShot));
        GameObject shotGO = new GameObject(name);

        shotGO.transform.parent = shotTrack.transform;

        SortedDictionary <float, CinemaShot> sortedShots = new SortedDictionary <float, CinemaShot>();

        foreach (CinemaShot s in shotTrack.TimelineItems)
        {
            sortedShots.Add(s.CutTime, s);
        }

        float latestTime = 0;
        float length     = DEFAULT_SHOT_LENGTH;

        foreach (CinemaShot s in sortedShots.Values)
        {
            if (latestTime >= s.CutTime)
            {
                latestTime = Mathf.Max(latestTime, s.CutTime + s.Duration);
            }
            else
            {
                length = s.CutTime - latestTime;
                break;
            }
        }

        CinemaShot shot = shotGO.AddComponent <CinemaShot>();

        shot.CutTime    = latestTime;
        shot.ShotLength = length;

        return(shot);
    }
示例#11
0
    internal static CinemaMultiActorCurveClip CreateMultiActorClipCurve(MultiCurveTrack multiCurveTrack)
    {
        string     name = DirectorHelper.getCutsceneItemName(multiCurveTrack.gameObject, CURVE_CLIP_NAME_DEFAULT, typeof(CinemaMultiActorCurveClip));
        GameObject item = new GameObject(name);

        item.transform.parent = multiCurveTrack.transform;
        CinemaMultiActorCurveClip clip = item.AddComponent <CinemaMultiActorCurveClip>();

        SortedDictionary <float, CinemaMultiActorCurveClip> sortedItems = new SortedDictionary <float, CinemaMultiActorCurveClip>();

        foreach (CinemaMultiActorCurveClip c in multiCurveTrack.TimelineItems)
        {
            sortedItems.Add(c.Firetime, c);
        }

        float latestTime = 0;
        float length     = DEFAULT_CURVE_LENGTH;

        foreach (CinemaMultiActorCurveClip c in sortedItems.Values)
        {
            if (latestTime >= c.Firetime)
            {
                latestTime = Mathf.Max(latestTime, c.Firetime + c.Duration);
            }
            else
            {
                length = c.Firetime - latestTime;
                break;
            }
        }

        clip.Firetime = latestTime;
        clip.Duration = length;

        return(clip);
    }
示例#12
0
    /// <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();
    }
示例#13
0
    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);
    }
示例#14
0
        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);
        }