protected override void showContextMenu(Behaviour behaviour)
    {
        CinemaShot shot = behaviour as CinemaShot;

        if (shot == null)
        {
            return;
        }

        Camera[] cameras = GameObject.FindObjectsOfType <Camera>();

        GenericMenu createMenu = new GenericMenu();

        createMenu.AddItem(new GUIContent("Focus"), false, focusShot, shot);
        foreach (Camera c in cameras)
        {
            ContextSetCamera arg = new ContextSetCamera();
            arg.shot   = shot;
            arg.camera = c;
            createMenu.AddItem(new GUIContent(string.Format(MODIFY_CAMERA, c.gameObject.name)), false, setCamera, arg);
        }
        createMenu.AddSeparator(string.Empty);
        createMenu.AddItem(new GUIContent("Copy"), false, copyItem, behaviour);
        createMenu.AddSeparator(string.Empty);
        createMenu.AddItem(new GUIContent("Clear"), false, deleteItem, shot);
        createMenu.ShowAsContext();
    }
Beispiel #2
0
    protected override void showContextMenu(Behaviour behaviour)
    {
        CinemaShot shot = behaviour as CinemaShot;

        if (shot == null)
        {
            return;
        }

        Camera[] cameras = GameObject.FindObjectsOfType <Camera>();

        GenericMenu createMenu = new GenericMenu();

        createMenu.AddItem(new GUIContent("Focus"), false, focusShot, shot);
        {
            var __array1       = cameras;
            var __arrayLength1 = __array1.Length;
            for (int __i1 = 0; __i1 < __arrayLength1; ++__i1)
            {
                var c = (Camera)__array1[__i1];
                {
                    ContextSetCamera arg = new ContextSetCamera();
                    arg.shot   = shot;
                    arg.camera = c;
                    createMenu.AddItem(new GUIContent(string.Format(MODIFY_CAMERA, c.gameObject.name)), false, setCamera, arg);
                }
            }
        }
        createMenu.AddSeparator(string.Empty);
        createMenu.AddItem(new GUIContent("Copy"), false, copyItem, behaviour);
        createMenu.AddSeparator(string.Empty);
        createMenu.AddItem(new GUIContent("Clear"), false, deleteItem, shot);
        createMenu.ShowAsContext();
    }
    private void focusShot(object userData)
    {
        CinemaShot shot = userData as CinemaShot;

        if (shot.shotCamera != null)
        {
            SceneView.currentDrawingSceneView.AlignViewToObject(shot.shotCamera.transform);
        }
    }
Beispiel #4
0
    public override void Draw(DirectorControlState state)
    {
        CinemaShot shot = Wrapper.Behaviour as CinemaShot;

        if (shot == null)
        {
            return;
        }

        if (Selection.Contains(shot.gameObject))
        {
            GUI.Box(controlPosition, GUIContent.none, TimelineTrackControl.styles.ShotTrackItemSelectedStyle);
        }
        else
        {
            GUI.Box(controlPosition, GUIContent.none, TimelineTrackControl.styles.ShotTrackItemStyle);
        }


        // Draw Icon
        Color temp = GUI.color;

        GUI.color = (shot.shotCamera != null) ? new Color(0.19f, 0.76f, 0.84f) : Color.red;
        Rect icon = controlPosition;

        icon.x     += 4;
        icon.width  = 16;
        icon.height = 16;
        //GUI.DrawTexture(icon, shotIcon, ScaleMode.ScaleToFit, true, 0);
        GUI.Box(icon, actionIcon, GUIStyle.none);
        GUI.color = temp;

        Rect labelPosition = controlPosition;

        labelPosition.x      = icon.xMax;
        labelPosition.width -= (icon.width + 4);

        if (TrackControl.isExpanded)
        {
            labelPosition.height = TimelineTrackControl.ROW_HEIGHT;

            if (shot.shotCamera != null)
            {
                Rect extraInfo = labelPosition;
                extraInfo.y += TimelineTrackControl.ROW_HEIGHT;
                GUI.Label(extraInfo, string.Format("Camera: {0}", shot.shotCamera.name));
            }
        }
        DrawRenameLabel(shot.name, labelPosition);
    }
Beispiel #5
0
    private void focusShot(object userData)
    {
        CinemaShot shot = userData as CinemaShot;

        if (shot.shotCamera != null)
        {
            if (SceneView.currentDrawingSceneView != null)
            {
                SceneView.currentDrawingSceneView.AlignViewToObject(shot.shotCamera.transform);
            }
            else
            {
                Debug.Log("Focus is not supported in this version of Unity.");
            }
        }
    }
    public override void Draw(DirectorControlState state)
    {
        CinemaShot shot = Wrapper.Behaviour as CinemaShot;

        if (shot == null)
        {
            return;
        }

        Color temp = GUI.color;

        GUI.color = (shot.shotCamera != null) ? GUI.color : Color.red;
        if (Selection.activeGameObject == shot.gameObject)
        {
            GUI.Box(controlPosition, new GUIContent(shot.name), TimelineTrackControl.styles.ShotTrackItemSelectedStyle);
        }
        else
        {
            GUI.Box(controlPosition, new GUIContent(shot.name), TimelineTrackControl.styles.ShotTrackItemStyle);
        }
        GUI.color = temp;
    }
    /// <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();
    }
Beispiel #8
0
    protected override void showContextMenu(Behaviour behaviour)
    {
        CinemaShot shot = behaviour as CinemaShot;

        if (shot == null)
        {
            return;
        }

        Camera[] cameras = Object.FindObjectsOfType <Camera>();

        GenericMenu createMenu = new GenericMenu();

        createMenu.AddItem(new GUIContent("Rename"), false, renameItem, behaviour);
        createMenu.AddItem(new GUIContent("Copy"), false, copyItem, behaviour);
        createMenu.AddItem(new GUIContent("Delete"), false, deleteItem, shot);
        createMenu.AddSeparator(string.Empty);
        createMenu.AddItem(new GUIContent("Focus"), false, focusShot, shot);
        foreach (Camera c in cameras)
        {
            ContextSetCamera arg = new ContextSetCamera
            {
                shot   = shot,
                camera = c
            };
            createMenu.AddItem(new GUIContent(string.Format(MODIFY_CAMERA, c.gameObject.name)), false, setCamera, arg);
        }
        Cutscene.ForeachDir(CinemaShot.animDir, path =>
        {
            ContextSetAnimationClip arg = new ContextSetAnimationClip
            {
                shot     = shot,
                clipName = path
            };
            createMenu.AddItem(new GUIContent(string.Format(MODIFY_ANIMATION, path)), false, setAnimationClip, arg);
        });
        createMenu.ShowAsContext();
    }
Beispiel #9
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);
    }