예제 #1
0
        override public void Skip()
        {
            MainCamera mainCam = KickStarter.mainCamera;

            if (mainCam)
            {
                _Camera cam = linkedCamera;

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

                if (cam)
                {
                    if (cam is GameCameraThirdPerson)
                    {
                        GameCameraThirdPerson tpCam = (GameCameraThirdPerson)cam;
                        tpCam.ResetRotation();
                    }

                    cam.MoveCameraInstant();
                    mainCam.SetGameCamera(cam);
                }
            }
        }
예제 #2
0
        private void DisplayInputList(GameCameraThirdPerson _target)
        {
            string result = "";

            if (_target.allowMouseWheelZooming)
            {
                result += "\n";
                result += "- Mouse ScrollWheel";
            }
            if (!_target.isDragControlled)
            {
                if (_target.spinLock == GameCameraThirdPerson.RotationLock.Free)
                {
                    result += "\n";
                    result += "- " + _target.spinAxis;
                }
                if (_target.pitchLock == GameCameraThirdPerson.RotationLock.Free)
                {
                    result += "\n";
                    result += "- " + _target.pitchAxis;
                }
            }
            if (_target.toggleCursor)
            {
                result += "\n";
                result += "- ToggleCursor";
            }

            if (result != "")
            {
                EditorGUILayout.Space();
                EditorGUILayout.LabelField("Required inputs:", EditorStyles.boldLabel);
                EditorGUILayout.HelpBox("The following input axes are available for the chosen settings:" + result, MessageType.Info);
            }
        }
예제 #3
0
        override public void Skip()
        {
            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 (cam is GameCameraThirdPerson)
                    {
                        GameCameraThirdPerson tpCam = (GameCameraThirdPerson)cam;
                        tpCam.ResetRotation();
                    }

                    mainCam.SetGameCamera(cam);

                    cam.MoveCameraInstant();
                    mainCam.SnapToAttached();
                }
            }
        }
예제 #4
0
        override public void ShowGUI(List <ActionParameter> parameters)
        {
            parameterID = Action.ChooseParameterGUI("Third-person camera:", parameters, parameterID, ParameterType.GameObject);
            if (parameterID >= 0)
            {
                constantID   = 0;
                linkedCamera = null;
            }
            else
            {
                linkedCamera = (GameCameraThirdPerson)EditorGUILayout.ObjectField("Third-person camera:", linkedCamera, typeof(GameCameraThirdPerson), true);

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

            controlPitch = EditorGUILayout.Toggle("Control pitch?", controlPitch);
            if (controlPitch)
            {
                newPitchAngle = EditorGUILayout.FloatField("New pitch angle:", newPitchAngle);
            }

            controlSpin = EditorGUILayout.Toggle("Control spin?", controlSpin);
            if (controlSpin)
            {
                newSpinAngle       = EditorGUILayout.FloatField("New spin angle:", newSpinAngle);
                isRelativeToTarget = EditorGUILayout.Toggle("Spin relative to target?", isRelativeToTarget);
            }

            if (controlPitch || controlSpin)
            {
                transitionTimeParameterID = Action.ChooseParameterGUI("Transition time (s):", parameters, transitionTimeParameterID, ParameterType.Float);
                if (transitionTimeParameterID < 0)
                {
                    transitionTime = EditorGUILayout.FloatField("Transition time (s):", transitionTime);
                }

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

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

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

            AfterRunningOption();
        }
예제 #5
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);
            }
        }
예제 #7
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);
        }
예제 #8
0
        public override void OnInspectorGUI()
        {
            GameCameraThirdPerson _target = (GameCameraThirdPerson)target;

            // Target
            EditorGUILayout.BeginVertical("Button");
            EditorGUILayout.LabelField("Target", EditorStyles.boldLabel);
            _target.targetIsPlayer = EditorGUILayout.Toggle("Is player?", _target.targetIsPlayer);
            if (!_target.targetIsPlayer)
            {
                _target.target = (Transform)EditorGUILayout.ObjectField("Target transform:", _target.target, typeof(Transform), true);
            }
            _target.verticalOffset   = EditorGUILayout.FloatField("Vertical offset:", _target.verticalOffset);
            _target.horizontalOffset = EditorGUILayout.FloatField("Horizontal offset:", _target.horizontalOffset);
            EditorGUILayout.EndVertical();

            // Distance
            EditorGUILayout.BeginVertical("Button");
            EditorGUILayout.LabelField("Distance", EditorStyles.boldLabel);
            _target.distance = EditorGUILayout.FloatField("Distance from target:", _target.distance);
            _target.allowMouseWheelZooming = EditorGUILayout.Toggle("Mousewheel zooming?", _target.allowMouseWheelZooming);
            _target.detectCollisions       = EditorGUILayout.Toggle("Detect wall collisions?", _target.detectCollisions);

            if (_target.detectCollisions)
            {
                _target.collisionOffset = EditorGUILayout.FloatField("Collision offset:", _target.collisionOffset);
                if (_target.collisionOffset < 0f)
                {
                    _target.collisionOffset = 0f;
                }
            }
            if (_target.allowMouseWheelZooming || _target.detectCollisions)
            {
                _target.minDistance = EditorGUILayout.FloatField("Mininum distance:", _target.minDistance);
            }
            if (_target.allowMouseWheelZooming)
            {
                _target.maxDistance = EditorGUILayout.FloatField("Maximum distance:", _target.maxDistance);
            }
            EditorGUILayout.EndVertical();

            // Spin
            EditorGUILayout.BeginVertical("Button");
            EditorGUILayout.BeginHorizontal();
            EditorGUILayout.LabelField("Spin rotation", EditorStyles.boldLabel, GUILayout.Width(130f));
            _target.spinLock = (GameCameraThirdPerson.RotationLock)EditorGUILayout.EnumPopup(_target.spinLock);
            EditorGUILayout.EndHorizontal();
            if (_target.spinLock != GameCameraThirdPerson.RotationLock.Locked)
            {
                _target.spinSpeed        = EditorGUILayout.FloatField("Speed:", _target.spinSpeed);
                _target.spinAccleration  = EditorGUILayout.FloatField("Acceleration:", _target.spinAccleration);
                _target.spinDeceleration = EditorGUILayout.FloatField("Deceleration:", _target.spinDeceleration);
                _target.isDragControlled = EditorGUILayout.Toggle("Drag-controlled?", _target.isDragControlled);
                if (!_target.isDragControlled)
                {
                    _target.spinAxis = EditorGUILayout.TextField("Input axis:", _target.spinAxis);
                }
                _target.invertSpin          = EditorGUILayout.Toggle("Invert?", _target.invertSpin);
                _target.toggleCursor        = EditorGUILayout.Toggle("Cursor must be locked?", _target.toggleCursor);
                _target.resetSpinWhenSwitch = EditorGUILayout.Toggle("Reset angle on switch?", _target.resetSpinWhenSwitch);

                if (_target.spinLock == GameCameraThirdPerson.RotationLock.Limited)
                {
                    _target.maxSpin = EditorGUILayout.FloatField("Maximum angle:", _target.maxSpin);
                }
            }
            else
            {
                _target.alwaysBehind = EditorGUILayout.Toggle("Always behind target?", _target.alwaysBehind);
                if (_target.alwaysBehind)
                {
                    _target.spinAccleration = EditorGUILayout.FloatField("Acceleration:", _target.spinAccleration);
                    _target.spinOffset      = EditorGUILayout.FloatField("Offset angle:", _target.spinOffset);
                }
            }
            EditorGUILayout.EndVertical();

            // Pitch
            EditorGUILayout.BeginVertical("Button");
            EditorGUILayout.BeginHorizontal();
            EditorGUILayout.LabelField("Pitch rotation", EditorStyles.boldLabel, GUILayout.Width(130f));
            _target.pitchLock = (GameCameraThirdPerson.RotationLock)EditorGUILayout.EnumPopup(_target.pitchLock);
            EditorGUILayout.EndHorizontal();
            if (_target.pitchLock != GameCameraThirdPerson.RotationLock.Locked)
            {
                _target.pitchSpeed        = EditorGUILayout.FloatField("Speed:", _target.pitchSpeed);
                _target.pitchAccleration  = EditorGUILayout.FloatField("Acceleration:", _target.pitchAccleration);
                _target.pitchDeceleration = EditorGUILayout.FloatField("Deceleration:", _target.pitchDeceleration);
                _target.isDragControlled  = EditorGUILayout.Toggle("Drag-controlled?", _target.isDragControlled);
                if (!_target.isDragControlled)
                {
                    _target.pitchAxis = EditorGUILayout.TextField("Input axis:", _target.pitchAxis);
                }
                _target.invertPitch          = EditorGUILayout.Toggle("Invert?", _target.invertPitch);
                _target.resetPitchWhenSwitch = EditorGUILayout.Toggle("Reset angle on switch?", _target.resetPitchWhenSwitch);

                if (_target.pitchLock == GameCameraThirdPerson.RotationLock.Limited)
                {
                    _target.maxPitch = EditorGUILayout.FloatField("Maximum angle:", _target.maxPitch);
                }
            }
            else
            {
                _target.maxPitch = EditorGUILayout.FloatField("Fixed angle:", _target.maxPitch);
            }
            EditorGUILayout.EndVertical();

            DisplayInputList(_target);

            if (GUI.changed)
            {
                EditorUtility.SetDirty(_target);
            }
        }
예제 #9
0
        public override void OnInspectorGUI()
        {
            GameCameraThirdPerson _target = (GameCameraThirdPerson)target;

            // Target
            EditorGUILayout.BeginVertical("Button");
            EditorGUILayout.LabelField("Target", EditorStyles.boldLabel);
            _target.targetIsPlayer = EditorGUILayout.Toggle("Is player?", _target.targetIsPlayer);
            if (!_target.targetIsPlayer)
            {
                _target.target = (Transform)EditorGUILayout.ObjectField("Target transform:", _target.target, typeof(Transform), true);
            }
            _target.horizontalOffset = EditorGUILayout.FloatField("Horizontal offset:", _target.horizontalOffset);
            _target.verticalOffset   = EditorGUILayout.FloatField("Vertical offset:", _target.verticalOffset);
            EditorGUILayout.EndVertical();

            // Distance
            EditorGUILayout.BeginVertical("Button");
            EditorGUILayout.LabelField("Distance", EditorStyles.boldLabel);
            _target.distance = EditorGUILayout.FloatField("Distance from target:", _target.distance);
            _target.allowMouseWheelZooming = EditorGUILayout.Toggle("Mousewheel zooming?", _target.allowMouseWheelZooming);
            _target.detectCollisions       = EditorGUILayout.Toggle("Detect wall collisions?", _target.detectCollisions);

            if (_target.detectCollisions)
            {
                _target.collisionOffset = EditorGUILayout.FloatField("Collision offset:", _target.collisionOffset);
                if (_target.collisionOffset < 0f)
                {
                    _target.collisionOffset = 0f;
                }
                _target.collisionLayerMask = AdvGame.LayerMaskField("Collision layer(s):", _target.collisionLayerMask);
            }
            if (_target.allowMouseWheelZooming || _target.detectCollisions)
            {
                _target.minDistance = EditorGUILayout.FloatField("Mininum distance:", _target.minDistance);
            }
            if (_target.allowMouseWheelZooming)
            {
                _target.maxDistance = EditorGUILayout.FloatField("Maximum distance:", _target.maxDistance);
            }
            EditorGUILayout.EndVertical();

            // Spin
            EditorGUILayout.BeginVertical("Button");
            EditorGUILayout.BeginHorizontal();
            EditorGUILayout.LabelField("Spin rotation", EditorStyles.boldLabel, GUILayout.Width(130f));
            _target.spinLock = (RotationLock)EditorGUILayout.EnumPopup(_target.spinLock);
            EditorGUILayout.EndHorizontal();
            if (_target.spinLock != RotationLock.Locked)
            {
                _target.spinSpeed        = EditorGUILayout.FloatField("Speed:", _target.spinSpeed);
                _target.spinAccleration  = EditorGUILayout.FloatField("Acceleration:", _target.spinAccleration);
                _target.spinDeceleration = EditorGUILayout.FloatField("Deceleration:", _target.spinDeceleration);
                _target.isDragControlled = EditorGUILayout.Toggle("Drag-controlled?", _target.isDragControlled);
                if (!_target.isDragControlled)
                {
                    _target.spinAxis = EditorGUILayout.TextField("Input axis:", _target.spinAxis);
                }
                _target.inputAffectsSpeed   = EditorGUILayout.ToggleLeft("Scale speed with input magnitude?", _target.inputAffectsSpeed);
                _target.invertSpin          = EditorGUILayout.Toggle("Invert?", _target.invertSpin);
                _target.toggleCursor        = EditorGUILayout.Toggle("Cursor must be locked?", _target.toggleCursor);
                _target.resetSpinWhenSwitch = EditorGUILayout.Toggle("Reset angle on switch?", _target.resetSpinWhenSwitch);

                if (_target.spinLock == RotationLock.Limited)
                {
                    _target.maxSpin = EditorGUILayout.FloatField("Maximum angle:", _target.maxSpin);
                }
            }

            if (_target.spinLock != RotationLock.Free)
            {
                _target.alwaysBehind = EditorGUILayout.Toggle("Always behind target?", _target.alwaysBehind);
                if (_target.alwaysBehind)
                {
                    _target.spinAccleration = EditorGUILayout.FloatField("Acceleration:", _target.spinAccleration);
                    _target.spinOffset      = EditorGUILayout.FloatField("Offset angle:", _target.spinOffset);
                }
            }
            EditorGUILayout.EndVertical();

            // Pitch
            EditorGUILayout.BeginVertical("Button");
            EditorGUILayout.BeginHorizontal();
            EditorGUILayout.LabelField("Pitch rotation", EditorStyles.boldLabel, GUILayout.Width(130f));
            _target.pitchLock = (RotationLock)EditorGUILayout.EnumPopup(_target.pitchLock);
            EditorGUILayout.EndHorizontal();
            if (_target.pitchLock != RotationLock.Locked)
            {
                _target.pitchSpeed        = EditorGUILayout.FloatField("Speed:", _target.pitchSpeed);
                _target.pitchAccleration  = EditorGUILayout.FloatField("Acceleration:", _target.pitchAccleration);
                _target.pitchDeceleration = EditorGUILayout.FloatField("Deceleration:", _target.pitchDeceleration);
                _target.isDragControlled  = EditorGUILayout.Toggle("Drag-controlled?", _target.isDragControlled);
                if (!_target.isDragControlled)
                {
                    _target.pitchAxis = EditorGUILayout.TextField("Input axis:", _target.pitchAxis);
                }
                _target.inputAffectsSpeed    = EditorGUILayout.ToggleLeft("Scale speed with input magnitude?", _target.inputAffectsSpeed);
                _target.invertPitch          = EditorGUILayout.Toggle("Invert?", _target.invertPitch);
                _target.resetPitchWhenSwitch = EditorGUILayout.Toggle("Reset angle on switch?", _target.resetPitchWhenSwitch);

                if (_target.pitchLock == RotationLock.Limited)
                {
                    _target.maxPitch = EditorGUILayout.FloatField("Maximum angle:", _target.maxPitch);
                    _target.minPitch = EditorGUILayout.FloatField("Minimum angle:", _target.minPitch);
                }
            }
            else
            {
                _target.maxPitch = EditorGUILayout.FloatField("Fixed angle:", _target.maxPitch);
            }
            EditorGUILayout.EndVertical();

            EditorGUILayout.BeginVertical("Button");
            EditorGUILayout.LabelField("Depth of field", EditorStyles.boldLabel);
            _target.focalPointIsTarget = EditorGUILayout.Toggle("Focal point is target object?", _target.focalPointIsTarget);
            if (!_target.focalPointIsTarget)
            {
                _target.focalDistance = EditorGUILayout.FloatField("Focal distance:", _target.focalDistance);
            }
            else if (Application.isPlaying)
            {
                EditorGUILayout.LabelField("Focal distance: " + _target.focalDistance.ToString(), EditorStyles.miniLabel);
            }
            EditorGUILayout.EndVertical();

            DisplayInputList(_target);

            UnityVersionHandler.CustomSetDirty(_target);
        }
예제 #10
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);
        }
        private void DisplayInputList(GameCameraThirdPerson _target)
        {
            string result = "";

            if (_target.allowMouseWheelZooming)
            {
                result += "\n";
                result += "- Mouse ScrollWheel";
            }
            if (!_target.isDragControlled)
            {
                if (_target.spinLock == GameCameraThirdPerson.RotationLock.Free)
                {
                    result += "\n";
                    result += "- " + _target.spinAxis;
                }
                if (_target.pitchLock == GameCameraThirdPerson.RotationLock.Free)
                {
                    result += "\n";
                    result += "- " + _target.pitchAxis;
                }
            }
            if (_target.toggleCursor)
            {
                result += "\n";
                result += "- ToggleCursor";
            }

            if (result != "")
            {
                EditorGUILayout.Space ();
                EditorGUILayout.LabelField ("Required inputs:", EditorStyles.boldLabel);
                EditorGUILayout.HelpBox ("The following input axes are available for the chosen settings:" + result, MessageType.Info);
            }
        }
예제 #12
0
 public override void AssignValues(List<ActionParameter> parameters)
 {
     linkedCamera = AssignFile <GameCameraThirdPerson> (parameters, parameterID, constantID, linkedCamera);
     transitionTime = AssignFloat (parameters, transitionTimeParameterID, transitionTime);
 }
예제 #13
0
        public override void ShowGUI(List<ActionParameter> parameters)
        {
            parameterID = Action.ChooseParameterGUI ("Third-person camera:", parameters, parameterID, ParameterType.GameObject);
            if (parameterID >= 0)
            {
                constantID = 0;
                linkedCamera = null;
            }
            else
            {
                linkedCamera = (GameCameraThirdPerson) EditorGUILayout.ObjectField ("Third-person camera:", linkedCamera, typeof (GameCameraThirdPerson), true);

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

            controlPitch = EditorGUILayout.Toggle ("Control pitch?", controlPitch);
            if (controlPitch)
            {
                newPitchAngle = EditorGUILayout.FloatField ("New pitch angle:", newPitchAngle);
            }

            controlSpin = EditorGUILayout.Toggle ("Control spin?", controlSpin);
            if (controlSpin)
            {
                newSpinAngle = EditorGUILayout.FloatField ("New spin angle:", newSpinAngle);
                isRelativeToTarget = EditorGUILayout.Toggle ("Spin relative to target?", isRelativeToTarget);
            }

            if (controlPitch || controlSpin)
            {

                transitionTimeParameterID = Action.ChooseParameterGUI ("Transition time (s):", parameters, transitionTimeParameterID, ParameterType.Float);
                if (transitionTimeParameterID < 0)
                {
                    transitionTime = EditorGUILayout.FloatField ("Transition time (s):", transitionTime);
                }

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

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

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

            AfterRunningOption ();
        }
예제 #14
0
 override public void AssignValues(List <ActionParameter> parameters)
 {
     linkedCamera   = AssignFile <GameCameraThirdPerson> (parameters, parameterID, constantID, linkedCamera);
     transitionTime = AssignFloat(parameters, transitionTimeParameterID, transitionTime);
 }
예제 #15
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);
        }
예제 #16
0
        public override void OnInspectorGUI()
        {
            GameCameraThirdPerson _target = (GameCameraThirdPerson)target;

            // Target
            CustomGUILayout.BeginVertical();
            EditorGUILayout.LabelField("Target", EditorStyles.boldLabel);
            _target.targetIsPlayer = CustomGUILayout.Toggle("Is player?", _target.targetIsPlayer, "", "If True, the camera will follow the active Player");
            if (!_target.targetIsPlayer)
            {
                _target.target = (Transform)CustomGUILayout.ObjectField <Transform> ("Target transform:", _target.target, true, "", "The object that the camera should follow");
            }
            _target.horizontalOffset = CustomGUILayout.FloatField("Horizontal offset:", _target.horizontalOffset, "", "The horizontal position offset");
            _target.verticalOffset   = CustomGUILayout.FloatField("Vertical offset:", _target.verticalOffset, "", "The vertical position offset");
            CustomGUILayout.EndVertical();

            // Distance
            CustomGUILayout.BeginVertical();
            EditorGUILayout.LabelField("Distance", EditorStyles.boldLabel);
            _target.distance = CustomGUILayout.FloatField("Distance from target:", _target.distance, "", "The normal distance to keep from its target");
            _target.allowMouseWheelZooming = CustomGUILayout.Toggle("Mousewheel zooming?", _target.allowMouseWheelZooming, "", "If True, the mousewheel can be used to zoom the camera's distance from the target");
            _target.detectCollisions       = CustomGUILayout.Toggle("Detect wall collisions?", _target.detectCollisions, "", "If True, then the camera will detect Colliders to try to avoid clipping through walls");

            if (_target.detectCollisions)
            {
                _target.collisionRadius = CustomGUILayout.FloatField("Collision radius:", _target.collisionRadius, "", "The size of the SphereCast to use when detecting collisions");
                if (_target.collisionRadius < 0f)
                {
                    _target.collisionRadius = 0f;
                }
                _target.collisionLayerMask = AdvGame.LayerMaskField("Collision layer(s):", _target.collisionLayerMask, "The layers to check for when detecting collisions");
            }
            if (_target.allowMouseWheelZooming || _target.detectCollisions)
            {
                _target.minDistance = CustomGUILayout.FloatField("Mininum distance:", _target.minDistance, "", "The minimum distance to keep from its target");
            }
            if (_target.allowMouseWheelZooming)
            {
                _target.maxDistance = CustomGUILayout.FloatField("Maximum distance:", _target.maxDistance, "", "The maximum distance to keep from its target");
            }
            CustomGUILayout.EndVertical();

            // Spin
            CustomGUILayout.BeginVertical();
            EditorGUILayout.BeginHorizontal();
            EditorGUILayout.LabelField(new GUIContent("Spin rotation", "How spin rotation is affected"), EditorStyles.boldLabel, GUILayout.Width(130f));
            _target.spinLock = (RotationLock)EditorGUILayout.EnumPopup(_target.spinLock);
            EditorGUILayout.EndHorizontal();
            if (_target.spinLock != RotationLock.Locked)
            {
                _target.spinSpeed                    = CustomGUILayout.FloatField("Speed:", _target.spinSpeed, "", "The speed of spin rotations");
                _target.spinAccleration              = CustomGUILayout.FloatField("Acceleration:", _target.spinAccleration, "", "The acceleration of spin rotations");
                _target.spinDeceleration             = CustomGUILayout.FloatField("Deceleration:", _target.spinDeceleration, "", "The deceleration of spin rotations");
                _target.isDragControlled             = CustomGUILayout.Toggle("Drag-controlled?", _target.isDragControlled, "", "If True, then the camera can be drag-controlled");
                _target.canRotateDuringCutscenes     = CustomGUILayout.ToggleLeft("Can rotate during cutscenes?", _target.canRotateDuringCutscenes, "", "If True, then spin and pitch can be altered when gameplay is blocked");
                _target.canRotateDuringConversations = CustomGUILayout.ToggleLeft("Can rotate during Conversations?", _target.canRotateDuringConversations, "", "If True, then spin and pitch can be altered when a Conversation is active");
                if (!_target.isDragControlled)
                {
                    _target.spinAxis = CustomGUILayout.TextField("Input axis:", _target.spinAxis, "", "The name of the Input axis that controls spin rotation");
                }
                _target.inputAffectsSpeed   = CustomGUILayout.ToggleLeft("Scale speed with input magnitude?", _target.inputAffectsSpeed, "", "If True, then the magnitude of the input vector affects the magnitude of the rotation speed");
                _target.invertSpin          = CustomGUILayout.Toggle("Invert?", _target.invertSpin, "", "If True, then the direction of spin rotations will be reversed");
                _target.toggleCursor        = CustomGUILayout.Toggle("Cursor must be locked?", _target.toggleCursor, "", "If True, then the cursor must be locked for spin rotation to occur");
                _target.resetSpinWhenSwitch = CustomGUILayout.Toggle("Reset angle on switch?", _target.resetSpinWhenSwitch, "", "If True, then the spin rotation will be reset when the camera is made active");

                if (_target.spinLock == RotationLock.Limited)
                {
                    _target.maxSpin = CustomGUILayout.FloatField("Maximum angle:", _target.maxSpin, "", "The maximum spin angle");
                }
            }

            if (_target.spinLock != RotationLock.Free)
            {
                _target.alwaysBehind = CustomGUILayout.Toggle("Always behind target?", _target.alwaysBehind, "", "If True, then the camera's spin rotation will be relative to the target's rotation");
                if (_target.alwaysBehind)
                {
                    _target.spinAccleration = CustomGUILayout.FloatField("Acceleration:", _target.spinAccleration, "", "The acceleration of spin rotations");
                    _target.spinOffset      = CustomGUILayout.FloatField("Offset angle:", _target.spinOffset, "", "The offset in spin (yaw) angle");
                }
            }
            CustomGUILayout.EndVertical();

            // Pitch
            CustomGUILayout.BeginVertical();
            EditorGUILayout.BeginHorizontal();
            EditorGUILayout.LabelField(new GUIContent("Pitch rotation", "How pitch rotation is affected"), EditorStyles.boldLabel, GUILayout.Width(130f));
            _target.pitchLock = (RotationLock)EditorGUILayout.EnumPopup(_target.pitchLock);
            EditorGUILayout.EndHorizontal();
            if (_target.pitchLock != RotationLock.Locked)
            {
                _target.pitchSpeed                   = CustomGUILayout.FloatField("Speed:", _target.pitchSpeed, "", "The speed of pitch rotations");
                _target.pitchAccleration             = CustomGUILayout.FloatField("Acceleration:", _target.pitchAccleration, "", "The acceleration of pitch rotations");
                _target.pitchDeceleration            = CustomGUILayout.FloatField("Deceleration:", _target.pitchDeceleration, "", "The deceleration of pitch rotations");
                _target.isDragControlled             = CustomGUILayout.Toggle("Drag-controlled?", _target.isDragControlled, "", "If True, then the camera can be drag-controlled");
                _target.canRotateDuringConversations = CustomGUILayout.ToggleLeft("Can rotate during Conversations?", _target.canRotateDuringConversations, "", "If True, then spin and pitch can be altered when a Conversation is active");
                if (!_target.isDragControlled)
                {
                    _target.pitchAxis = CustomGUILayout.TextField("Input axis:", _target.pitchAxis, "", "The name of the Input axis that controls pitch rotation");
                }
                _target.inputAffectsSpeed    = CustomGUILayout.ToggleLeft("Scale speed with input magnitude?", _target.inputAffectsSpeed, "", "If True, then the magnitude of the input vector affects the magnitude of the rotation speed");
                _target.invertPitch          = CustomGUILayout.Toggle("Invert?", _target.invertPitch, "", "If True, then the direction of pitch rotations will be reversed");
                _target.resetPitchWhenSwitch = CustomGUILayout.Toggle("Reset angle on switch?", _target.resetPitchWhenSwitch, "", "If True, then the pitch rotation will be reset when the camera is made active");

                if (_target.pitchLock == RotationLock.Limited)
                {
                    _target.maxPitch = CustomGUILayout.FloatField("Maximum angle:", _target.maxPitch, "", "The maximum pitch angle");
                    _target.minPitch = CustomGUILayout.FloatField("Minimum angle:", _target.minPitch, "", "The minimum pitch angle");
                }
            }
            else
            {
                _target.maxPitch = CustomGUILayout.FloatField("Fixed angle:", _target.maxPitch, "", "The fixed pitch angle");
            }
            CustomGUILayout.EndVertical();

            CustomGUILayout.BeginVertical();
            EditorGUILayout.LabelField("Depth of field", EditorStyles.boldLabel);
            _target.focalPointIsTarget = CustomGUILayout.Toggle("Focal point is target object?", _target.focalPointIsTarget, "", "If True, then the focal distance will match the distance to the target");
            if (!_target.focalPointIsTarget)
            {
                _target.focalDistance = CustomGUILayout.FloatField("Focal distance:", _target.focalDistance, "", "The camera's focal distance.  When the MainCamera is attached to this camera, it can be read through script with 'AC.KickStarter.mainCamera.GetFocalDistance()' and used to update your post-processing method.");
            }
            else if (Application.isPlaying)
            {
                EditorGUILayout.LabelField("Focal distance: " + _target.focalDistance.ToString(), EditorStyles.miniLabel);
            }
            CustomGUILayout.EndVertical();

            DisplayInputList(_target);

            UnityVersionHandler.CustomSetDirty(_target);
        }