Beispiel #1
0
    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);
    }
    public override void Draw(DirectorControlState state)
    {
        CinemaGlobalAction action = Wrapper.Behaviour as CinemaGlobalAction;

        if (action == null)
        {
            return;
        }

        if (IsSelected)
        {
            GUI.Box(controlPosition, GUIContent.none, TimelineTrackControl.styles.GlobalTrackItemSelectedStyle);
        }
        else
        {
            GUI.Box(controlPosition, GUIContent.none, TimelineTrackControl.styles.GlobalTrackItemStyle);
        }

        DrawRenameLabel(action.name, controlPosition);
    }
    /// <summary>
    /// Update and Draw the inspector
    /// </summary>
    public override void OnInspectorGUI()
    {
        visualTrack.Update();

        EditorGUILayout.Foldout(shotFoldout, "Shot List");
        ShotTrack track = base.serializedObject.targetObject as ShotTrack;

        TimelineItem[] items = track.TimelineItems;
        for (int i = 0; i < items.Length; i++)
        {
            CinemaGlobalAction shot = items[i] as CinemaGlobalAction;
            shot.name = EditorGUILayout.TextField(new GUIContent("Shot Name"), shot.name);

            EditorGUI.indentLevel++;


            // Check if it is an actor event.
            CinemaShot cinemaShot = shot as CinemaShot;
            if (cinemaShot != null)
            {
                cinemaShot.shotCamera = EditorGUILayout.ObjectField(new GUIContent("Camera"), cinemaShot.shotCamera, typeof(Camera), true) as Camera;
            }
            else
            {
                // Display something for non-default shots
            }

            shot.Firetime = EditorGUILayout.FloatField(new GUIContent("Cut Time"), shot.Firetime);
            shot.Duration = EditorGUILayout.FloatField(new GUIContent("Shot Length"), shot.Duration);
            EditorGUI.indentLevel--;
        }

        if (GUILayout.Button("Add New Shot"))
        {
            CutsceneItemFactory.CreateNewShot(track);
        }
        visualTrack.ApplyModifiedProperties();
    }