Esempio n. 1
0
        override public void ShowGUI(List <ActionParameter> parameters)
        {
            bool showWaitOption = false;

            returnToLast = EditorGUILayout.Toggle("Return to last gameplay?", returnToLast);

            if (!returnToLast)
            {
                parameterID = Action.ChooseParameterGUI("New camera:", parameters, parameterID, ParameterType.GameObject);
                if (parameterID >= 0)
                {
                    constantID   = 0;
                    linkedCamera = null;
                }
                else
                {
                    linkedCamera = (_Camera)EditorGUILayout.ObjectField("New camera:", linkedCamera, typeof(_Camera), true);

                    constantID   = FieldToID <_Camera> (linkedCamera, constantID);
                    linkedCamera = IDToField <_Camera> (linkedCamera, constantID, true);
                }

                if (linkedCamera && linkedCamera is GameCameraAnimated)
                {
                    GameCameraAnimated animatedCamera = (GameCameraAnimated)linkedCamera;
                    if (animatedCamera.animatedCameraType == AnimatedCameraType.PlayWhenActive && transitionTime <= 0f)
                    {
                        showWaitOption = true;
                    }
                }
            }

            if (linkedCamera is GameCamera25D && !returnToLast)
            {
                transitionTime = 0f;
            }
            else
            {
                transitionTime = EditorGUILayout.FloatField("Transition time (s):", transitionTime);

                if (transitionTime > 0f)
                {
                    moveMethod     = (MoveMethod)EditorGUILayout.EnumPopup("Move method:", moveMethod);
                    showWaitOption = true;

                    if (moveMethod == MoveMethod.CustomCurve)
                    {
                        timeCurve = EditorGUILayout.CurveField("Time curve:", timeCurve);
                    }
                }
            }

            if (showWaitOption)
            {
                willWait = EditorGUILayout.Toggle("Wait until finish?", willWait);
            }

            AfterRunningOption();
        }
        public override void OnInspectorGUI()
        {
            GameCameraAnimated _target = (GameCameraAnimated)target;

            if (_target.GetComponent <Animation>() == null)
            {
                EditorGUILayout.HelpBox("This camera type requires an Animation component.", MessageType.Warning);
            }

            EditorGUILayout.BeginVertical("Button");
            _target.animatedCameraType = (AnimatedCameraType)EditorGUILayout.EnumPopup("Animated camera type:", _target.animatedCameraType);
            _target.clip = (AnimationClip)EditorGUILayout.ObjectField("Animation clip:", _target.clip, typeof(AnimationClip), false);

            if (_target.animatedCameraType == AnimatedCameraType.PlayWhenActive)
            {
                _target.loopClip    = EditorGUILayout.Toggle("Loop animation?", _target.loopClip);
                _target.playOnStart = EditorGUILayout.Toggle("Play on start?", _target.playOnStart);
            }
            else if (_target.animatedCameraType == AnimatedCameraType.SyncWithTargetMovement)
            {
                _target.pathToFollow   = (Paths)EditorGUILayout.ObjectField("Path to follow:", _target.pathToFollow, typeof(Paths), true);
                _target.targetIsPlayer = EditorGUILayout.Toggle("Target is player?", _target.targetIsPlayer);

                if (!_target.targetIsPlayer)
                {
                    _target.target = (Transform)EditorGUILayout.ObjectField("Target:", _target.target, typeof(Transform), true);
                }
            }
            EditorGUILayout.EndVertical();

            if (_target.animatedCameraType == AnimatedCameraType.SyncWithTargetMovement)
            {
                EditorGUILayout.Space();
                EditorGUILayout.BeginVertical("Button");
                EditorGUILayout.LabelField("Cursor influence", EditorStyles.boldLabel);
                _target.followCursor = EditorGUILayout.Toggle("Follow cursor?", _target.followCursor);
                if (_target.followCursor)
                {
                    _target.cursorInfluence = EditorGUILayout.Vector2Field("Panning factor", _target.cursorInfluence);
                }
                EditorGUILayout.EndVertical();
            }

            if (GUI.changed)
            {
                EditorUtility.SetDirty(_target);
            }
        }
Esempio n. 3
0
        public override void Skip()
        {
            MainCamera mainCam = KickStarter.mainCamera;

            if (runtimeLinkedCamera && mainCam.attachedCamera != runtimeLinkedCamera)
            {
                if (runtimeLinkedCamera is GameCameraThirdPerson)
                {
                    GameCameraThirdPerson tpCam = (GameCameraThirdPerson)runtimeLinkedCamera;
                    tpCam.ResetRotation();
                }
                else if (runtimeLinkedCamera is GameCameraAnimated)
                {
                    GameCameraAnimated animCam = (GameCameraAnimated)runtimeLinkedCamera;
                    animCam.PlayClip();
                }

                runtimeLinkedCamera.MoveCameraInstant();
                mainCam.SetGameCamera(runtimeLinkedCamera);
            }
        }
        override public void Skip()
        {
            MainCamera mainCam = KickStarter.mainCamera;

            if (linkedCamera != null && mainCam.attachedCamera != linkedCamera)
            {
                if (linkedCamera is GameCameraThirdPerson)
                {
                    GameCameraThirdPerson tpCam = (GameCameraThirdPerson)linkedCamera;
                    tpCam.ResetRotation();
                }
                else if (linkedCamera is GameCameraAnimated)
                {
                    GameCameraAnimated animCam = (GameCameraAnimated)linkedCamera;
                    animCam.PlayClip();
                }

                linkedCamera.MoveCameraInstant();
                mainCam.SetGameCamera(linkedCamera);
            }
        }
Esempio n. 5
0
        public override void OnInspectorGUI()
        {
            GameCameraAnimated _target = (GameCameraAnimated)target;

            if (_target.GetComponent <Animation>() == null)
            {
                EditorGUILayout.HelpBox("This camera type requires an Animation component.", MessageType.Warning);
            }

            EditorGUILayout.BeginVertical("Button");
            _target.animatedCameraType = (AnimatedCameraType)CustomGUILayout.EnumPopup("Animated camera type:", _target.animatedCameraType, "", "The way in which animations are played");
            _target.clip = (AnimationClip)CustomGUILayout.ObjectField <AnimationClip> ("Animation clip:", _target.clip, false, "", "The animation to play when this camera is made active");

            if (_target.animatedCameraType == AnimatedCameraType.PlayWhenActive)
            {
                _target.loopClip    = CustomGUILayout.Toggle("Loop animation?", _target.loopClip, "", "If True, then the animation will loop");
                _target.playOnStart = CustomGUILayout.Toggle("Play on start?", _target.playOnStart, "", "If True, then the animation will play when the scene begins, rather than waiting for it to become active");
            }
            else if (_target.animatedCameraType == AnimatedCameraType.SyncWithTargetMovement)
            {
                _target.pathToFollow   = (Paths)CustomGUILayout.ObjectField <Paths> ("Path to follow:", _target.pathToFollow, true, "", "The Paths object to sync with animation");
                _target.targetIsPlayer = CustomGUILayout.Toggle("Target is Player?", _target.targetIsPlayer, "", "If True, the camera will follow the active Player");

                if (!_target.targetIsPlayer)
                {
                    _target.target = (Transform)CustomGUILayout.ObjectField <Transform> ("Target:", _target.target, true, "", "The object for the camera to follow");
                }
            }
            EditorGUILayout.EndVertical();

            if (_target.animatedCameraType == AnimatedCameraType.SyncWithTargetMovement)
            {
                EditorGUILayout.Space();
                _target.ShowCursorInfluenceGUI();
            }

            UnityVersionHandler.CustomSetDirty(_target);
        }
Esempio n. 6
0
        public override float Run()
        {
            if (!isRunning)
            {
                isRunning = true;
                MainCamera mainCam = KickStarter.mainCamera;

                if (runtimeLinkedCamera && mainCam.attachedCamera != runtimeLinkedCamera)
                {
                    if (runtimeLinkedCamera is GameCameraThirdPerson)
                    {
                        GameCameraThirdPerson tpCam = (GameCameraThirdPerson)runtimeLinkedCamera;
                        tpCam.ResetRotation();
                    }
                    else if (runtimeLinkedCamera is GameCameraAnimated)
                    {
                        GameCameraAnimated animCam = (GameCameraAnimated)runtimeLinkedCamera;
                        animCam.PlayClip();
                    }

                    runtimeLinkedCamera.MoveCameraInstant();
                    mainCam.Crossfade(transitionTime, runtimeLinkedCamera, fadeCurve);

                    if (transitionTime > 0f && willWait)
                    {
                        return(transitionTime);
                    }
                }
            }
            else
            {
                isRunning = false;
            }

            return(0f);
        }
Esempio n. 7
0
        override public float Run()
        {
            if (!isRunning)
            {
                isRunning = true;

                MainCamera mainCam = KickStarter.mainCamera;

                if (mainCam)
                {
                    _Camera cam = linkedCamera;

                    if (returnToLast)
                    {
                        cam = mainCam.GetLastGameplayCamera();
                    }

                    if (cam)
                    {
                        if (mainCam.attachedCamera != cam)
                        {
                            if (cam is GameCameraThirdPerson)
                            {
                                GameCameraThirdPerson tpCam = (GameCameraThirdPerson)cam;
                                tpCam.ResetRotation();
                            }
                            else if (cam is GameCameraAnimated)
                            {
                                GameCameraAnimated animCam = (GameCameraAnimated)cam;
                                animCam.PlayClip();
                            }

                            if (transitionTime > 0f && linkedCamera is GameCamera25D)
                            {
                                mainCam.SetGameCamera(cam, 0f);
                                ACDebug.LogWarning("Switching to a 2.5D camera (" + linkedCamera.name + ") must be instantaneous.", linkedCamera);
                            }
                            else
                            {
                                mainCam.SetGameCamera(cam, transitionTime, moveMethod, timeCurve, retainPreviousSpeed);

                                if (willWait)
                                {
                                    if (transitionTime > 0f)
                                    {
                                        return(transitionTime);
                                    }
                                    else if (linkedCamera is GameCameraAnimated)
                                    {
                                        return(defaultPauseTime);
                                    }
                                }
                            }
                        }
                    }
                }
            }
            else
            {
                if (linkedCamera is GameCameraAnimated && willWait)
                {
                    GameCameraAnimated animatedCamera = (GameCameraAnimated)linkedCamera;
                    if (animatedCamera.isPlaying())
                    {
                        return(defaultPauseTime);
                    }
                    else
                    {
                        isRunning = false;
                        return(0f);
                    }
                }
                else
                {
                    isRunning = false;
                    return(0f);
                }
            }

            return(0f);
        }
        public override void OnInspectorGUI()
        {
            GameCameraAnimated _target = (GameCameraAnimated)target;

            if (_target.GetComponent <Animation>() == null)
            {
                EditorGUILayout.HelpBox("This camera type requires an Animation component.", MessageType.Warning);
            }

            EditorGUILayout.BeginVertical("Button");
            _target.animatedCameraType = (AnimatedCameraType)EditorGUILayout.EnumPopup("Animated camera type:", _target.animatedCameraType);
            _target.clip = (AnimationClip)EditorGUILayout.ObjectField("Animation clip:", _target.clip, typeof(AnimationClip), false);

            if (_target.animatedCameraType == AnimatedCameraType.PlayWhenActive)
            {
                _target.loopClip    = EditorGUILayout.Toggle("Loop animation?", _target.loopClip);
                _target.playOnStart = EditorGUILayout.Toggle("Play on start?", _target.playOnStart);
            }
            else if (_target.animatedCameraType == AnimatedCameraType.SyncWithTargetMovement)
            {
                _target.pathToFollow   = (Paths)EditorGUILayout.ObjectField("Path to follow:", _target.pathToFollow, typeof(Paths), true);
                _target.targetIsPlayer = EditorGUILayout.Toggle("Target is Player?", _target.targetIsPlayer);

                if (!_target.targetIsPlayer)
                {
                    _target.target = (Transform)EditorGUILayout.ObjectField("Target:", _target.target, typeof(Transform), true);
                }
            }
            EditorGUILayout.EndVertical();

            if (_target.animatedCameraType == AnimatedCameraType.SyncWithTargetMovement)
            {
                EditorGUILayout.Space();
                EditorGUILayout.BeginVertical("Button");
                EditorGUILayout.LabelField("Cursor influence", EditorStyles.boldLabel);
                _target.followCursor = EditorGUILayout.Toggle("Follow cursor?", _target.followCursor);
                if (_target.followCursor)
                {
                    _target.cursorInfluence           = EditorGUILayout.Vector2Field("Panning factor", _target.cursorInfluence);
                    _target.constrainCursorInfluenceX = EditorGUILayout.ToggleLeft("Constrain panning in X direction?", _target.constrainCursorInfluenceX);
                    if (_target.constrainCursorInfluenceX)
                    {
                        _target.limitCursorInfluenceX[0] = EditorGUILayout.Slider("Minimum X:", _target.limitCursorInfluenceX[0], -1.4f, 0f);
                        _target.limitCursorInfluenceX[1] = EditorGUILayout.Slider("Maximum X:", _target.limitCursorInfluenceX[1], 0f, 1.4f);
                    }
                    _target.constrainCursorInfluenceY = EditorGUILayout.ToggleLeft("Constrain panning in Y direction?", _target.constrainCursorInfluenceY);
                    if (_target.constrainCursorInfluenceY)
                    {
                        _target.limitCursorInfluenceY[0] = EditorGUILayout.Slider("Minimum Y:", _target.limitCursorInfluenceY[0], -1.4f, 0f);
                        _target.limitCursorInfluenceY[1] = EditorGUILayout.Slider("Maximum Y:", _target.limitCursorInfluenceY[1], 0f, 1.4f);
                    }

                    if (Application.isPlaying && KickStarter.mainCamera != null && KickStarter.mainCamera.attachedCamera == _target)
                    {
                        EditorGUILayout.HelpBox("Changes made to this panel will not be felt until the MainCamera switches to this camera again.", MessageType.Info);
                    }
                }
                EditorGUILayout.EndVertical();
            }

            UnityVersionHandler.CustomSetDirty(_target);
        }
Esempio n. 9
0
        public void SetGameCamera(_Camera newCamera)
        {
            if (newCamera == null)
            {
                return;
            }

            if (attachedCamera != null && attachedCamera is GameCamera25D)
            {
                if (newCamera is GameCamera25D)
                {
                }
                else
                {
                    RemoveBackground();
                }
            }

            if (_camera == null && GetComponent <Camera>())
            {
                _camera = GetComponent <Camera>();
            }
            _camera.ResetProjectionMatrix();
            attachedCamera = newCamera;
            attachedCamera.SetCameraComponent();

            if (attachedCamera && attachedCamera._camera)
            {
                _camera.farClipPlane  = attachedCamera._camera.farClipPlane;
                _camera.nearClipPlane = attachedCamera._camera.nearClipPlane;
                _camera.orthographic  = attachedCamera._camera.orthographic;
            }

            // Set LookAt
            if (attachedCamera is GameCamera)
            {
                GameCamera gameCam = (GameCamera)attachedCamera;
                cursorAffectsRotation = gameCam.followCursor;
                lookAtAmount          = gameCam.cursorInfluence;
            }
            else if (attachedCamera is GameCameraAnimated)
            {
                GameCameraAnimated gameCam = (GameCameraAnimated)attachedCamera;
                if (gameCam.animatedCameraType == AnimatedCameraType.SyncWithTargetMovement)
                {
                    cursorAffectsRotation = gameCam.followCursor;
                    lookAtAmount          = gameCam.cursorInfluence;
                }
                else
                {
                    cursorAffectsRotation = false;
                }
            }
            else
            {
                cursorAffectsRotation = false;
            }

            // Set background
            if (attachedCamera is GameCamera25D)
            {
                GameCamera25D cam25D = (GameCamera25D)attachedCamera;
                cam25D.SetActiveBackground();
            }

            // TransparencySortMode
            if (attachedCamera is GameCamera2D)
            {
                _camera.transparencySortMode = TransparencySortMode.Orthographic;
            }
            else if (attachedCamera)
            {
                if (attachedCamera._camera.orthographic)
                {
                    _camera.transparencySortMode = TransparencySortMode.Orthographic;
                }
                else
                {
                    _camera.transparencySortMode = TransparencySortMode.Perspective;
                }
            }

            // UFPS
            if (KickStarter.settingsManager.movementMethod == MovementMethod.UltimateFPS)
            {
                UltimateFPSIntegration._Update(KickStarter.stateHandler.gameState);
            }
        }
Esempio n. 10
0
        override public float Run()
        {
            if (!isRunning)
            {
                isRunning = true;

                MainCamera mainCam = KickStarter.mainCamera;

                if (mainCam)
                {
                    _Camera cam = linkedCamera;

                    if (returnToLast && mainCam.lastNavCamera)
                    {
                        if (mainCam.lastNavCamera != null && mainCam.attachedCamera == mainCam.lastNavCamera)
                        {
                            cam = (_Camera)mainCam.lastNavCamera2;
                        }
                        else
                        {
                            cam = (_Camera)mainCam.lastNavCamera;
                        }
                    }

                    if (cam)
                    {
                        if (mainCam.attachedCamera != cam)
                        {
                            if (cam is GameCameraThirdPerson)
                            {
                                GameCameraThirdPerson tpCam = (GameCameraThirdPerson)cam;
                                tpCam.ResetRotation();
                            }
                            else if (cam is GameCameraAnimated)
                            {
                                GameCameraAnimated animCam = (GameCameraAnimated)cam;
                                animCam.PlayClip();
                            }

                            mainCam.SetGameCamera(cam);
                            if (transitionTime > 0f)
                            {
                                if (linkedCamera is GameCamera25D)
                                {
                                    mainCam.SnapToAttached();
                                    Debug.LogWarning("Switching to a 2.5D camera (" + linkedCamera.name + ") must be instantaneous.");
                                }
                                else
                                {
                                    mainCam.SmoothChange(transitionTime, moveMethod, timeCurve);

                                    if (willWait)
                                    {
                                        return(transitionTime);
                                    }
                                }
                            }
                            else
                            {
                                cam.MoveCameraInstant();
                                mainCam.SnapToAttached();

                                if (linkedCamera is GameCameraAnimated && willWait)
                                {
                                    return(defaultPauseTime);
                                }
                            }
                        }
                    }
                }
            }
            else
            {
                if (linkedCamera is GameCameraAnimated && willWait)
                {
                    GameCameraAnimated animatedCamera = (GameCameraAnimated)linkedCamera;
                    if (animatedCamera.isPlaying())
                    {
                        return(defaultPauseTime);
                    }
                    else
                    {
                        isRunning = false;
                        return(0f);
                    }
                }
                else
                {
                    isRunning = false;
                    return(0f);
                }
            }

            return(0f);
        }