示例#1
0
        //override to show shot previews
        protected override void OnClipGUI(Rect rect)
        {
            if (targetShot == null || rect.width < 40)
            {
                return;
            }

            if (Prefs.showShotThumbnails)
            {
                if (thumbRefresher == 0 || thumbRefresher % Prefs.thumbnailsRefreshInterval == 0)
                {
                    var res    = EditorTools.GetGameViewSize();
                    var width  = (int)res.x;
                    var height = (int)res.y;
                    thumbnail = targetShot.GetRenderTexture(width, height);
                }

                thumbRefresher++;

                if (thumbnail != null)
                {
                    GUI.backgroundColor = Color.clear;
                    var style = new GUIStyle("Box");
                    style.alignment = TextAnchor.MiddleCenter;
                    var thumbRect = new Rect(0, 0, 100, rect.height);

                    if (blendIn > 0)
                    {
                        var previousClip = GetPreviousClip();
                        if (previousClip != null && previousClip.endTime > this.startTime)
                        {
                            thumbRect.x += (blendIn / length) * rect.width;
                        }
                    }

                    if (blendOut > 0)
                    {
                        var nextClip = GetNextClip();
                        if (nextClip != null && nextClip.startTime < this.endTime)
                        {
                            thumbRect.width = Mathf.Min(thumbRect.width, rect.width - ((blendOut / length) * rect.width));
                        }
                    }

                    GUI.Box(thumbRect, thumbnail, style);
                    GUI.backgroundColor = Color.white;
                }

                if (targetShot.name != ShotCamera.DEFAULT_NAME)
                {
                    var bevelRect = rect;
                    bevelRect.center += new Vector2(1, 1);
                    GUI.color         = Color.white;
                    GUI.Label(bevelRect, targetShot.name, Styles.centerLabel);
                    GUI.color = new Color(0, 0, 0, 0.7f);
                    GUI.Label(rect, targetShot.name, Styles.centerLabel);
                    GUI.color = Color.white;
                }
            }
        }
        void OnGUI()
        {
            if (isRendering)
            {
                Repaint();
            }

            settings.renderFormat = (RenderFormat)EditorGUILayout.EnumPopup("Render Format", settings.renderFormat);
            GUILayout.BeginHorizontal();
            settings.folderName = EditorGUILayout.TextField("SubFolder In Project", settings.folderName);
            if (GUILayout.Button("F", GUILayout.Width(20), GUILayout.Height(14)))
            {
                OpenTargetFolder();
            }
            GUILayout.EndHorizontal();
            settings.fileName = EditorGUILayout.TextField("Filename", settings.fileName);

            GUILayout.BeginVertical("box");

            if (settings.renderFormat == RenderFormat.PNGImageSequence || settings.renderFormat == RenderFormat.EXRImageSequence)
            {
                settings.splitRenderBuffer = EditorGUILayout.Toggle("Render Passes", settings.splitRenderBuffer);
            }
            else
            {
                settings.resolutionWidth = Mathf.Clamp(EditorGUILayout.IntField("Resolution Width", settings.resolutionWidth), 64, 1920);
            }

            settings.framerate = Mathf.Clamp(EditorGUILayout.IntField("Frame Rate", settings.framerate), 2, 60);
            EditorGUILayout.LabelField("Resolution", EditorTools.GetGameViewSize().ToString("0"));
            EditorGUILayout.HelpBox("Rendering Resolution is taken from the Game Window.\nYou can create custom resolutions with the '+' button through the second dropdown in the Game window toolbar (where it usually reads 'Free Aspect').", MessageType.None);

            GUILayout.EndVertical();

            if (cutscene == null)
            {
                EditorGUILayout.HelpBox("Cutscene is null or the Cutscene Editor is not open", MessageType.Error);
            }

            if (cutscene.cameraTrack == null)
            {
                EditorGUILayout.HelpBox("Cutscene has no Camera Track", MessageType.Warning);
            }

            GUI.enabled = cutscene != null && cutscene.cameraTrack != null && !isRendering;
            if (GUILayout.Button(isRendering? "RENDERING..." : "RENDER", GUILayout.Height(50)))
            {
                Begin();
            }

            GUI.enabled = true;
            if (isRendering && GUILayout.Button("CANCEL"))
            {
                Done();
            }
        }
示例#3
0
        protected override void OnUpdate(float time, float previousTime)
        {
            if (steadyCamEffect > 0 && time != previousTime)
            {
                DirectorCamera.ApplyNoise(steadyCamEffect, GetClipWeight(time, 1f));
            }


            if (blendInEffect == BlendInEffectType.FadeIn)
            {
                if (time <= blendIn)
                {
                    var color = Color.black;
                    color.a = Easing.Ease(EaseType.QuadraticInOut, 1, 0, GetClipWeight(time));
                    DirectorGUI.UpdateFade(color);
                }
                else if (time < length - blendOut)
                {
                    DirectorGUI.UpdateFade(Color.clear);
                }
            }

            if (blendOutEffect == BlendOutEffectType.FadeOut)
            {
                if (time >= length - blendOut)
                {
                    var color = Color.black;
                    color.a = Easing.Ease(EaseType.QuadraticInOut, 1, 0, GetClipWeight(time));
                    DirectorGUI.UpdateFade(color);
                }
                else if (time > blendIn)
                {
                    DirectorGUI.UpdateFade(Color.clear);
                }
            }

            if (blendInEffect == BlendInEffectType.CrossDissolve && previousShot != null && previousShot.targetShot != null)
            {
                if (time <= blendIn)
                {
                    var res = new Vector2(Screen.width, Screen.height);
                                        #if UNITY_EDITOR
                    res = EditorTools.GetGameViewSize();
                                        #endif

                    var dissolver = previousShot.targetShot.GetRenderTexture((int)res.x, (int)res.y);
                    var ease      = Easing.Ease(EaseType.QuadraticInOut, 0, 1, GetClipWeight(time));
                    DirectorGUI.UpdateDissolve(dissolver, ease);
                }
                else
                {
                    DirectorGUI.UpdateDissolve(null, 0);
                }
            }
        }
示例#4
0
        public override void OnGUI(Rect rect)
        {
            GUILayout.BeginVertical("box");

            scrollPos = EditorGUILayout.BeginScrollView(scrollPos, false, false);
            foreach (var shot in Object.FindObjectsOfType <ShotCamera>())
            {
                var res     = EditorTools.GetGameViewSize();
                var texture = shot.GetRenderTexture((int)res.x, (int)res.y);
                if (GUILayout.Button(texture, GUILayout.Width(262), GUILayout.Height(120)))
                {
                    callback(shot);
                    editorWindow.Close();
                    return;
                }
                var r = GUILayoutUtility.GetLastRect();
                r.x      += 10;
                r.y      += 10;
                r.width  -= 20;
                r.height  = 18;
                GUI.color = new Color(0.2f, 0.2f, 0.2f, 0.8f);
                GUI.DrawTexture(r, Slate.Styles.whiteTexture);
                GUI.color = Color.white;
                GUI.Label(r, shot.name, Styles.leftLabel);
            }
            EditorGUILayout.EndScrollView();

            GUILayout.Space(10);

            if (GUILayout.Button("Create Shot"))
            {
                callback(ShotCamera.Create(director.context.transform));
                editorWindow.Close();
            }

            GUILayout.Space(10);

            GUILayout.EndVertical();
        }
示例#5
0
        public override void OnInspectorGUI()
        {
            base.ShowCommonInspector();


            serializedObject.Update();
            EditorGUILayout.PropertyField(blendInEffectProp);
            EditorGUILayout.PropertyField(blendOutEffectProp);
            EditorGUILayout.PropertyField(steadyCamEffectProp);
            serializedObject.ApplyModifiedProperties();

            if (action.parent.children.OfType <CameraShot>().FirstOrDefault() == action)
            {
                if (action.blendInEffect == CameraShot.BlendInEffectType.EaseIn)
                {
                    EditorGUILayout.HelpBox("The 'Ease In' option has no effect in the first shot clip of the track.", MessageType.Warning);
                }
                if (action.blendInEffect == CameraShot.BlendInEffectType.CrossDissolve)
                {
                    EditorGUILayout.HelpBox("The 'Cross Dissolve' option has no usable effect in the first shot clip of the track.", MessageType.Warning);
                }
            }



            if (action.targetShot == null)
            {
                EditorGUILayout.HelpBox("Select or Create a Shot Camera to be used by this clip.", MessageType.Error);
            }

            if (GUILayout.Button(action.targetShot == null? "Select Shot" : "Replace Shot"))
            {
                if (action.targetShot == null || EditorUtility.DisplayDialog("Replace Shot", "Selecting a new target shot will reset all animation data of this clip.", "OK", "Cancel"))
                {
                    ShotPicker.Show(Event.current.mousePosition, action.root, (shot) => { action.targetShot = shot; });
                }
            }

            if (action.targetShot == null && GUILayout.Button("Create Shot"))
            {
                action.targetShot = ShotCamera.Create(action.root.context.transform);
            }

            if (action.targetShot != null)
            {
                if (GUILayout.Button("Find in Scene"))
                {
                    Selection.activeGameObject = action.targetShot.gameObject;
                }

                var lastRect = GUILayoutUtility.GetLastRect();
                var rect     = new Rect(lastRect.x, lastRect.yMax + 5, lastRect.width, 200);

                var res     = EditorTools.GetGameViewSize();
                var texture = action.targetShot.GetRenderTexture((int)res.x, (int)res.y);
                var style   = new GUIStyle("Box");
                style.alignment = TextAnchor.MiddleCenter;
                GUI.Box(rect, texture, style);

                if (action.targetShot.dynamicController.composer.trackingMode == DynamicCameraController.Composer.TrackingMode.FrameComposition)
                {
                    var scale       = Mathf.Min(rect.width / res.x, rect.height / res.y);
                    var result      = new Vector2((res.x * scale), (res.y * scale));
                    var boundedRect = new Rect(0, 0, result.x, result.y);
                    boundedRect.center = rect.center;
                    GUI.BeginGroup(boundedRect);
                    action.targetShot.dynamicController.DoGUI(action.targetShot, boundedRect);
                    GUI.EndGroup();
                }


                GUILayout.Space(205);

                var helpRect = new Rect(rect.x + 10, rect.yMax - 20, rect.width - 20, 16);
                GUI.color = EditorGUIUtility.isProSkin? new Color(0, 0, 0, 0.6f) : new Color(1, 1, 1, 0.6f);
                GUI.DrawTexture(helpRect, Slate.Styles.whiteTexture);
                GUI.color = Color.white;
                GUI.Label(helpRect, "Left: Rotate, Middle: Pan, Right: Dolly, Alt+Right: Zoom");

                var e = Event.current;
                if (rect.Contains(e.mousePosition))
                {
                    EditorGUIUtility.AddCursorRect(rect, MouseCursor.Pan);
                    if (e.type == EventType.MouseDrag)
                    {
                        Undo.RecordObject(action.targetShot.transform, "Shot Change");
                        Undo.RecordObject(action.targetShot.cam, "Shot Change");
                        Undo.RecordObject(action.targetShot, "Shot Change");

                        var in2DMode = false;
                        var sc       = UnityEditor.SceneView.lastActiveSceneView;
                        if (sc != null)
                        {
                            in2DMode = sc.in2DMode;
                        }

                        //look
                        if (e.button == 0 && !in2DMode)
                        {
                            var deltaRot = new Vector3(e.delta.y, e.delta.x, 0) * 0.5f;
                            action.targetShot.localEulerAngles += deltaRot;
                            e.Use();
                        }
                        //pan
                        if (e.button == 2 || (e.button == 0 && in2DMode))
                        {
                            var deltaPos = new Vector3(-e.delta.x, e.delta.y, 0) * (e.shift? 0.01f : 0.05f);
                            action.targetShot.transform.Translate(deltaPos);
                            e.Use();
                        }
                        //dolly in/out
                        if (e.button == 1 && !e.alt)
                        {
                            action.targetShot.transform.Translate(0, 0, e.delta.x * 0.05f);
                            e.Use();
                        }
                        //fov
                        if (e.button == 1 && e.alt)
                        {
                            action.fieldOfView -= e.delta.x;
                            e.Use();
                        }

                        EditorUtility.SetDirty(action.targetShot.transform);
                        EditorUtility.SetDirty(action.targetShot.cam);
                        EditorUtility.SetDirty(action.targetShot);
                    }
                }



                ////The shot dynamic controller settings
                if (shotSerializedObject == null || shotSerializedObject.targetObject != action.targetShot)
                {
                    if (action.targetShot != null)
                    {
                        shotSerializedObject = new SerializedObject(action.targetShot);
                        shotControllerProp   = shotSerializedObject.FindProperty("_dynamicController");
                    }
                }

                EditorGUI.BeginChangeCheck();
                if (shotSerializedObject != null)
                {
                    shotSerializedObject.Update();
                    EditorGUILayout.PropertyField(shotControllerProp);
                    shotSerializedObject.ApplyModifiedProperties();
                }
                if (EditorGUI.EndChangeCheck())
                {
                    action.Validate();
                }
                /////

                base.ShowAnimatableParameters();
            }
        }
示例#6
0
        void OnGUI()
        {
            if (cutscene == null)
            {
                EditorGUILayout.HelpBox("Cutscene is null or the Cutscene Editor is not open", MessageType.Error);
                return;
            }

            if (cutscene.cameraTrack == null)
            {
                EditorGUILayout.HelpBox("Cutscene has no Camera Track", MessageType.Error);
                return;
            }

            ///----------------------------------------------------------------------------------------------

            settings.renderFormat = (RenderFormat)EditorGUILayout.EnumPopup("Render Format", settings.renderFormat);
            GUILayout.BeginHorizontal();
            settings.folderName = EditorGUILayout.TextField("Root Folder Name", settings.folderName);
            if (GUILayout.Button("O", GUILayout.Width(30), GUILayout.Height(14)))
            {
                OpenTargetFolder();
            }
            GUILayout.EndHorizontal();
            settings.fileNameMode = (RenderSettings.FileNameMode)EditorGUILayout.EnumPopup("File Name Mode", settings.fileNameMode);
            if (settings.fileNameMode == RenderSettings.FileNameMode.SpecifyFileName)
            {
                EditorGUI.indentLevel++;
                settings.fileName = EditorGUILayout.TextField("File Name", settings.fileName);
                EditorGUI.indentLevel--;
            }

            ///----------------------------------------------------------------------------------------------

            GUILayout.BeginVertical("box");
            if (settings.renderFormat == RenderFormat.MP4 || settings.renderFormat == RenderFormat.WebM)
            {
                settings.captureAudio = EditorGUILayout.Toggle("Capture Audio", settings.captureAudio);
            }
            settings.renderPasses = EditorGUILayout.Toggle("Render Passes", settings.renderPasses);
            settings.framerate    = Mathf.Clamp(EditorGUILayout.IntField("Frame Rate", settings.framerate), 2, 60);
            EditorGUILayout.LabelField("Resolution", EditorTools.GetGameViewSize().ToString("0"));
            EditorGUILayout.HelpBox("Rendering Resolution is taken from the Game Window.\nYou can create custom resolutions with the '+' button through the second dropdown in the Game window toolbar (where it usually reads 'Free Aspect').", MessageType.None);
            GUILayout.EndVertical();

            ///----------------------------------------------------------------------------------------------

            GUI.enabled = !isRendering;
            if (GUILayout.Button(isRendering ? "RENDERING..." : "RENDER", GUILayout.Height(50)))
            {
                Begin();
            }

            GUI.enabled = isRendering;
            if (GUILayout.Button("CANCEL"))
            {
                Done();
            }

            GUI.enabled = true;
            if (isRendering)
            {
                Repaint();
            }
        }