Beispiel #1
0
        public override void OnInspectorGUI()
        {
            GameCamera _target = (GameCamera)target;

            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();
            EditorGUILayout.Space();

            EditorGUILayout.BeginVertical("Button");
            EditorGUILayout.LabelField("X-axis movement", EditorStyles.boldLabel);

            _target.lockXLocAxis = EditorGUILayout.Toggle("Lock?", _target.lockXLocAxis);

            if (!_target.lockXLocAxis)
            {
                _target.xLocConstrainType = (CameraLocConstrainType)EditorGUILayout.EnumPopup("Affected by:", _target.xLocConstrainType);

                EditorGUILayout.BeginVertical("Button");
                if (_target.xLocConstrainType == CameraLocConstrainType.SideScrolling)
                {
                    _target.xFreedom = EditorGUILayout.FloatField("Track freedom:", _target.xFreedom);
                }
                else
                {
                    _target.xGradient = EditorGUILayout.FloatField("Influence:", _target.xGradient);
                    _target.xOffset   = EditorGUILayout.FloatField("Offset:", _target.xOffset);
                }
                EditorGUILayout.EndVertical();

                _target.limitX = EditorGUILayout.BeginToggleGroup("Constrain?", _target.limitX);

                EditorGUILayout.BeginVertical("Button");
                _target.constrainX[0] = EditorGUILayout.FloatField("Minimum:", _target.constrainX[0]);
                _target.constrainX[1] = EditorGUILayout.FloatField("Maximum:", _target.constrainX[1]);
                EditorGUILayout.EndVertical();

                EditorGUILayout.EndToggleGroup();
            }

            EditorGUILayout.EndVertical();
            EditorGUILayout.Space();

            EditorGUILayout.BeginVertical("Button");
            EditorGUILayout.LabelField("Y-axis movement", EditorStyles.boldLabel);

            _target.lockYLocAxis = EditorGUILayout.Toggle("Lock?", _target.lockYLocAxis);

            if (!_target.lockYLocAxis)
            {
                _target.yLocConstrainType = (CameraLocConstrainType)EditorGUILayout.EnumPopup("Affected by:", _target.yLocConstrainType);

                if (_target.yLocConstrainType == CameraLocConstrainType.SideScrolling)
                {
                    EditorGUILayout.HelpBox("This option is not available for Y-movement", MessageType.Warning);
                }
                else
                {
                    EditorGUILayout.BeginVertical("Button");
                    _target.yGradientLoc = EditorGUILayout.FloatField("Influence:", _target.yGradientLoc);
                    _target.yOffsetLoc   = EditorGUILayout.FloatField("Offset:", _target.yOffsetLoc);
                    EditorGUILayout.EndVertical();
                }

                _target.limitYLoc = EditorGUILayout.BeginToggleGroup("Constrain?", _target.limitYLoc);

                EditorGUILayout.BeginVertical("Button");
                _target.constrainYLoc[0] = EditorGUILayout.FloatField("Minimum:", _target.constrainYLoc[0]);
                _target.constrainYLoc[1] = EditorGUILayout.FloatField("Maximum:", _target.constrainYLoc[1]);
                EditorGUILayout.EndVertical();

                EditorGUILayout.EndToggleGroup();
            }

            EditorGUILayout.EndVertical();
            EditorGUILayout.Space();

            EditorGUILayout.BeginVertical("Button");
            EditorGUILayout.LabelField("Z-axis movement", EditorStyles.boldLabel);

            _target.lockZLocAxis = EditorGUILayout.Toggle("Lock?", _target.lockZLocAxis);

            if (!_target.lockZLocAxis)
            {
                _target.zLocConstrainType = (CameraLocConstrainType)EditorGUILayout.EnumPopup("Affected by:", _target.zLocConstrainType);

                EditorGUILayout.BeginVertical("Button");
                if (_target.zLocConstrainType == CameraLocConstrainType.SideScrolling)
                {
                    _target.zFreedom = EditorGUILayout.FloatField("Track freedom:", _target.zFreedom);
                }
                else
                {
                    _target.zGradient = EditorGUILayout.FloatField("Influence:", _target.zGradient);
                    _target.zOffset   = EditorGUILayout.FloatField("Offset:", _target.zOffset);
                }
                EditorGUILayout.EndVertical();

                _target.limitZ = EditorGUILayout.BeginToggleGroup("Constrain?", _target.limitZ);

                EditorGUILayout.BeginVertical("Button");
                _target.constrainZ[0] = EditorGUILayout.FloatField("Minimum:", _target.constrainZ[0]);
                _target.constrainZ[1] = EditorGUILayout.FloatField("Maximum:", _target.constrainZ[1]);
                EditorGUILayout.EndVertical();

                EditorGUILayout.EndToggleGroup();
            }

            EditorGUILayout.EndVertical();
            EditorGUILayout.Space();

            EditorGUILayout.BeginVertical("Button");
            EditorGUILayout.LabelField("Pitch rotation", EditorStyles.boldLabel);

            _target.lockXRotAxis = EditorGUILayout.Toggle("Lock?", _target.lockXRotAxis);

            if (!_target.lockXRotAxis)
            {
                _target.xRotConstrainType = (CameraLocConstrainType)EditorGUILayout.EnumPopup("Affected by:", _target.xRotConstrainType);

                if (_target.xRotConstrainType == CameraLocConstrainType.SideScrolling)
                {
                    EditorGUILayout.HelpBox("This option is not available for Pitch rotation", MessageType.Warning);
                }
                else
                {
                    EditorGUILayout.BeginVertical("Button");
                    _target.xGradientRot = EditorGUILayout.FloatField("Influence:", _target.xGradientRot);
                    _target.xOffsetRot   = EditorGUILayout.FloatField("Offset:", _target.xOffsetRot);
                    EditorGUILayout.EndVertical();
                }

                _target.limitXRot = EditorGUILayout.BeginToggleGroup("Constrain?", _target.limitXRot);

                EditorGUILayout.BeginVertical("Button");
                _target.constrainXRot[0] = EditorGUILayout.FloatField("Minimum:", _target.constrainXRot[0]);
                _target.constrainXRot[1] = EditorGUILayout.FloatField("Maximum:", _target.constrainXRot[1]);
                EditorGUILayout.EndVertical();

                EditorGUILayout.EndToggleGroup();
            }

            EditorGUILayout.EndVertical();
            EditorGUILayout.Space();

            EditorGUILayout.BeginVertical("Button");
            EditorGUILayout.LabelField("Spin rotation", EditorStyles.boldLabel);

            _target.lockYRotAxis = EditorGUILayout.Toggle("Lock?", _target.lockYRotAxis);

            if (!_target.lockYRotAxis)
            {
                _target.yRotConstrainType = (CameraRotConstrainType)EditorGUILayout.EnumPopup("Affected by:", _target.yRotConstrainType);

                if (_target.yRotConstrainType != CameraRotConstrainType.LookAtTarget)
                {
                    EditorGUILayout.BeginVertical("Button");
                    _target.directionInfluence = EditorGUILayout.FloatField("Target direction fac.:", _target.directionInfluence);
                    _target.yGradient          = EditorGUILayout.FloatField("Influence:", _target.yGradient);
                    _target.yOffset            = EditorGUILayout.FloatField("Offset:", _target.yOffset);
                    EditorGUILayout.EndVertical();

                    _target.limitY = EditorGUILayout.BeginToggleGroup("Constrain?", _target.limitY);

                    EditorGUILayout.BeginVertical("Button");
                    _target.constrainY[0] = EditorGUILayout.FloatField("Minimum:", _target.constrainY[0]);
                    _target.constrainY[1] = EditorGUILayout.FloatField("Maximum:", _target.constrainY[1]);
                    EditorGUILayout.EndVertical();

                    EditorGUILayout.EndToggleGroup();
                }
                else
                {
                    EditorGUILayout.BeginVertical("Button");
                    _target.directionInfluence = EditorGUILayout.FloatField("Target direction fac.:", _target.directionInfluence);
                    _target.targetHeight       = EditorGUILayout.FloatField("Target height offset:", _target.targetHeight);
                    _target.targetXOffset      = EditorGUILayout.FloatField("Target X offset:", _target.targetXOffset);
                    _target.targetZOffset      = EditorGUILayout.FloatField("Target Z offset:", _target.targetZOffset);
                    EditorGUILayout.EndVertical();
                }
            }

            EditorGUILayout.EndVertical();
            EditorGUILayout.Space();

            EditorGUILayout.BeginVertical("Button");
            EditorGUILayout.LabelField("Field of view", EditorStyles.boldLabel);

            _target.lockFOV = EditorGUILayout.Toggle("Lock?", _target.lockFOV);

            if (!_target.lockFOV)
            {
                EditorGUILayout.HelpBox("This value will vary with the target's distance from the camera.", MessageType.Info);

                EditorGUILayout.BeginVertical("Button");
                _target.FOVGradient = EditorGUILayout.FloatField("Influence:", _target.FOVGradient);
                _target.FOVOffset   = EditorGUILayout.FloatField("Offset:", _target.FOVOffset);
                EditorGUILayout.EndVertical();

                _target.limitFOV = EditorGUILayout.BeginToggleGroup("Constrain?", _target.limitFOV);

                EditorGUILayout.BeginVertical("Button");
                _target.constrainFOV[0] = EditorGUILayout.FloatField("Minimum:", _target.constrainFOV[0]);
                _target.constrainFOV[1] = EditorGUILayout.FloatField("Maximum:", _target.constrainFOV[1]);
                EditorGUILayout.EndVertical();

                EditorGUILayout.EndToggleGroup();
            }

            EditorGUILayout.EndVertical();
            EditorGUILayout.Space();

            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();
            EditorGUILayout.Space();

            if (!_target.lockXLocAxis || !_target.lockYRotAxis || !_target.lockFOV || !_target.lockYLocAxis || !_target.lockZLocAxis || _target.focalPointIsTarget)
            {
                EditorGUILayout.BeginVertical("Button");
                EditorGUILayout.LabelField("Target object to control camera movement", EditorStyles.boldLabel);

                _target.targetIsPlayer = EditorGUILayout.Toggle("Target is player?", _target.targetIsPlayer);

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

                _target.dampSpeed = EditorGUILayout.FloatField("Follow speed", _target.dampSpeed);
                _target.actFromDefaultPlayerStart = EditorGUILayout.Toggle("Use default PlayerStart?", _target.actFromDefaultPlayerStart);
                EditorGUILayout.EndVertical();
            }

            if (GUI.changed)
            {
                EditorUtility.SetDirty(_target);
            }
        }
        public override void OnInspectorGUI()
        {
            GameCamera _target = (GameCamera)target;

            _target.ShowCursorInfluenceGUI();
            EditorGUILayout.Space();

            EditorGUILayout.BeginVertical("Button");
            EditorGUILayout.LabelField("X-axis movement", EditorStyles.boldLabel);

            _target.lockXLocAxis = CustomGUILayout.Toggle("Lock?", _target.lockXLocAxis, "", "If True, movement in the X-axis is prevented");

            if (!_target.lockXLocAxis)
            {
                _target.xLocConstrainType = (CameraLocConstrainType)CustomGUILayout.EnumPopup("Affected by:", _target.xLocConstrainType, "", "The constrain type on X-axis movement");

                EditorGUILayout.BeginVertical("Button");
                if (_target.xLocConstrainType == CameraLocConstrainType.SideScrolling)
                {
                    _target.xFreedom = CustomGUILayout.FloatField("Track freedom:", _target.xFreedom, "", "The track freedom along the X-axis");
                }
                else
                {
                    _target.xGradient = CustomGUILayout.FloatField("Influence:", _target.xGradient, "", "The influence of the target's position on X-axis movement");
                }
                _target.xOffset = CustomGUILayout.FloatField("Offset:", _target.xOffset, "", "The X-axis position offset");
                EditorGUILayout.EndVertical();

                _target.limitX = CustomGUILayout.Toggle("Constrain?", _target.limitX, "", "If True, then X-axis movement will be limited to minimum and maximum values");
                if (_target.limitX)
                {
                    EditorGUILayout.BeginVertical("Button");
                    _target.constrainX[0] = CustomGUILayout.FloatField("Minimum constraint:", _target.constrainX[0], "", "The lower X-axis movement limit");
                    _target.constrainX[1] = CustomGUILayout.FloatField("Maximum constraint:", _target.constrainX[1], "", "The upper X-axis movement limit");
                    EditorGUILayout.EndVertical();
                }
            }

            EditorGUILayout.EndVertical();
            EditorGUILayout.Space();

            EditorGUILayout.BeginVertical("Button");
            EditorGUILayout.LabelField("Y-axis movement", EditorStyles.boldLabel);

            _target.lockYLocAxis = CustomGUILayout.Toggle("Lock?", _target.lockYLocAxis, "", "If True, movement in the Y-axis is prevented");

            if (!_target.lockYLocAxis)
            {
                _target.yLocConstrainType = (CameraLocConstrainType)CustomGUILayout.EnumPopup("Affected by:", _target.yLocConstrainType, "", "The constrain type on Y-axis movement");

                EditorGUILayout.BeginVertical("Button");
                if (_target.yLocConstrainType == CameraLocConstrainType.SideScrolling)
                {
                    _target.yFreedom = CustomGUILayout.FloatField("Track freedom:", _target.yFreedom, "", "The track freedom along the Y-axis");
                }
                else
                {
                    _target.yGradientLoc = CustomGUILayout.FloatField("Influence:", _target.yGradientLoc, "", "The influence of the target's position on Y-axis movement");
                }
                _target.yOffsetLoc = CustomGUILayout.FloatField("Offset:", _target.yOffsetLoc, "", "The Y-axis position offset");
                EditorGUILayout.EndVertical();

                _target.limitYLoc = CustomGUILayout.Toggle("Constrain?", _target.limitYLoc, "", "If True, then Y-axis movement will be limited to minimum and maximum values");
                if (_target.limitYLoc)
                {
                    EditorGUILayout.BeginVertical("Button");
                    _target.constrainYLoc[0] = CustomGUILayout.FloatField("Minimum constraint:", _target.constrainYLoc[0], "", "The lower Y-axis movement limit");
                    _target.constrainYLoc[1] = CustomGUILayout.FloatField("Maximum constraint:", _target.constrainYLoc[1], "", "The upper Y-axis movement limit");
                    EditorGUILayout.EndVertical();
                }
            }

            EditorGUILayout.EndVertical();
            EditorGUILayout.Space();

            EditorGUILayout.BeginVertical("Button");
            EditorGUILayout.LabelField("Z-axis movement", EditorStyles.boldLabel);

            _target.lockZLocAxis = CustomGUILayout.Toggle("Lock?", _target.lockZLocAxis, "", "If True, movement in the Z-axis is prevented");

            if (!_target.lockZLocAxis)
            {
                _target.zLocConstrainType = (CameraLocConstrainType)CustomGUILayout.EnumPopup("Affected by:", _target.zLocConstrainType, "", "The constrain type on Z-axis movement");

                EditorGUILayout.BeginVertical("Button");
                if (_target.zLocConstrainType == CameraLocConstrainType.SideScrolling)
                {
                    _target.zFreedom = CustomGUILayout.FloatField("Track freedom:", _target.zFreedom, "", "The track freedom along the Z-axis");
                }
                else
                {
                    _target.zGradient = CustomGUILayout.FloatField("Influence:", _target.zGradient, "", "The influence of the target's position on Z-axis movement");
                }
                _target.zOffset = CustomGUILayout.FloatField("Offset:", _target.zOffset, "", "The Z-axis position offset");
                EditorGUILayout.EndVertical();

                _target.limitZ = CustomGUILayout.Toggle("Constrain?", _target.limitZ, "", "If True, then Z-axis movement will be limited to minimum and maximum values");
                if (_target.limitZ)
                {
                    EditorGUILayout.BeginVertical("Button");
                    _target.constrainZ[0] = CustomGUILayout.FloatField("Minimum constraint:", _target.constrainZ[0], "", "The lower Z-axis movement limit");
                    _target.constrainZ[1] = CustomGUILayout.FloatField("Maximum constraint:", _target.constrainZ[1], "", "The upper Z-axis movement limit");
                    EditorGUILayout.EndVertical();
                }
            }

            EditorGUILayout.EndVertical();
            EditorGUILayout.Space();

            EditorGUILayout.BeginVertical("Button");
            EditorGUILayout.LabelField("Spin rotation", EditorStyles.boldLabel);

            _target.lockYRotAxis = CustomGUILayout.Toggle("Lock?", _target.lockYRotAxis, "", "If True, spin rotation is prevented");

            if (!_target.lockYRotAxis)
            {
                _target.yRotConstrainType = (CameraRotConstrainType)CustomGUILayout.EnumPopup("Affected by:", _target.yRotConstrainType, "", "The constrain type on spin rotation");

                if (_target.yRotConstrainType != CameraRotConstrainType.LookAtTarget)
                {
                    EditorGUILayout.BeginVertical("Button");
                    _target.directionInfluence = CustomGUILayout.FloatField("Target direction fac.:", _target.directionInfluence, "", "The influence that the target's facing direction has on the tracking position");
                    _target.yGradient          = CustomGUILayout.FloatField("Influence:", _target.yGradient, "", "The influence of the target's position on spin rotation");
                    _target.yOffset            = CustomGUILayout.FloatField("Offset:", _target.yOffset, "", "The spin rotation offset");
                    EditorGUILayout.EndVertical();
                }
                else
                {
                    EditorGUILayout.BeginVertical("Button");
                    _target.directionInfluence = CustomGUILayout.FloatField("Target direction fac.:", _target.directionInfluence, "", "The influence that the target's facing direction has on the tracking position");
                    _target.targetHeight       = CustomGUILayout.FloatField("Target height offset:", _target.targetHeight, "", "The target positional offset in the Y-axis");
                    _target.targetXOffset      = CustomGUILayout.FloatField("Target X offset:", _target.targetXOffset, "", "The target positional offset in the X-axis");
                    _target.targetZOffset      = CustomGUILayout.FloatField("Target Z offset:", _target.targetZOffset, "", "The target positional offset in the Z-axis");
                    EditorGUILayout.EndVertical();
                }

                _target.limitY = CustomGUILayout.Toggle("Constrain?", _target.limitY, "", "If True, then spin rotation will be limited to minimum and maximum values");
                if (_target.limitY)
                {
                    EditorGUILayout.BeginVertical("Button");
                    _target.constrainY[0] = CustomGUILayout.FloatField("Minimum constraint:", _target.constrainY[0], "", "The lower spin rotation limit");
                    _target.constrainY[1] = CustomGUILayout.FloatField("Maximum constraint:", _target.constrainY[1], "", "The upper spin rotation limit");
                    EditorGUILayout.EndVertical();
                }
            }

            EditorGUILayout.EndVertical();
            EditorGUILayout.Space();

            EditorGUILayout.BeginVertical("Button");
            EditorGUILayout.LabelField("Pitch rotation", EditorStyles.boldLabel);

            if (!_target.lockYRotAxis && _target.yRotConstrainType == CameraRotConstrainType.LookAtTarget)
            {
                EditorGUILayout.HelpBox("Pitch rotation is overriden by 'Look At Target' spin rotation.", MessageType.Info);

                _target.limitXRot = CustomGUILayout.Toggle("Constrain?", _target.limitXRot, "", "If True, then pitch rotation will be limited to minimum and maximum values");
            }
            else
            {
                _target.lockXRotAxis = CustomGUILayout.Toggle("Lock?", _target.lockXRotAxis, "", "If True, pitch rotation is prevented");

                if (!_target.lockXRotAxis)
                {
                    _target.xRotConstrainType = (CameraLocConstrainType)CustomGUILayout.EnumPopup("Affected by:", _target.xRotConstrainType, "", "The constrain type on pitch rotation");

                    if (_target.xRotConstrainType == CameraLocConstrainType.SideScrolling)
                    {
                        EditorGUILayout.HelpBox("This option is not available for Pitch rotation", MessageType.Warning);
                    }
                    else
                    {
                        EditorGUILayout.BeginVertical("Button");
                        _target.xGradientRot = CustomGUILayout.FloatField("Influence:", _target.xGradientRot, "", "The influence of the target's position on pitch rotation");
                        _target.xOffsetRot   = CustomGUILayout.FloatField("Offset:", _target.xOffsetRot, "", "The pitch rotation offset");
                        EditorGUILayout.EndVertical();
                    }

                    _target.limitXRot = CustomGUILayout.Toggle("Constrain?", _target.limitXRot, "", "If True, then pitch rotation will be limited to minimum and maximum values");
                    if (_target.limitXRot)
                    {
                        EditorGUILayout.BeginVertical("Button");
                        _target.constrainXRot[0] = CustomGUILayout.FloatField("Minimum constraint:", _target.constrainXRot[0], "", "The lower pitch rotation limit");
                        _target.constrainXRot[1] = CustomGUILayout.FloatField("Maximum constraint:", _target.constrainXRot[1], "", "The upper pitch rotation limit");
                        EditorGUILayout.EndVertical();
                    }
                }
            }

            EditorGUILayout.EndVertical();
            EditorGUILayout.Space();

            EditorGUILayout.BeginVertical("Button");
            if (_target.GetComponent <Camera>() && _target.GetComponent <Camera>().orthographic)
            {
                EditorGUILayout.LabelField("Orthographic size", EditorStyles.boldLabel);
            }
            else if (_target.GetComponentInChildren <Camera>() && _target.GetComponentInChildren <Camera>().orthographic)
            {
                EditorGUILayout.LabelField("Orthographic size", EditorStyles.boldLabel);
            }
            else
            {
                EditorGUILayout.LabelField("Field of view", EditorStyles.boldLabel);
            }

            _target.lockFOV = CustomGUILayout.Toggle("Lock?", _target.lockFOV, "", "If True, changing of the FOV is prevented");

            if (!_target.lockFOV)
            {
                EditorGUILayout.HelpBox("This value will vary with the target's distance from the camera.", MessageType.Info);

                EditorGUILayout.BeginVertical("Button");
                _target.FOVGradient = CustomGUILayout.FloatField("Influence:", _target.FOVGradient, "", "The influence of the target's position on FOV");
                _target.FOVOffset   = CustomGUILayout.FloatField("Offset:", _target.FOVOffset, "", "The FOV offset");
                EditorGUILayout.EndVertical();

                _target.limitFOV = CustomGUILayout.Toggle("Constrain?", _target.limitFOV, "", "If True, then FOV will be limited to minimum and maximum value");
                if (_target.limitFOV)
                {
                    EditorGUILayout.BeginVertical("Button");
                    _target.constrainFOV[0] = CustomGUILayout.FloatField("Minimum constraint:", _target.constrainFOV[0], "", "The lower FOV limit");
                    _target.constrainFOV[1] = CustomGUILayout.FloatField("Maximum constraint:", _target.constrainFOV[1], "", "The upper FOV limit");
                    EditorGUILayout.EndVertical();
                }
            }

            EditorGUILayout.EndVertical();
            EditorGUILayout.Space();

            EditorGUILayout.BeginVertical("Button");
            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);
            }
            EditorGUILayout.EndVertical();
            EditorGUILayout.Space();

            if (!_target.lockXLocAxis || !_target.lockYRotAxis || !_target.lockFOV || !_target.lockYLocAxis || !_target.lockZLocAxis || _target.focalPointIsTarget)
            {
                EditorGUILayout.BeginVertical("Button");
                EditorGUILayout.LabelField("Target object to control camera movement", EditorStyles.boldLabel);

                _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");
                }

                _target.dampSpeed = CustomGUILayout.FloatField("Follow speed:", _target.dampSpeed, "", "The follow speed when tracking a target");
                _target.actFromDefaultPlayerStart = CustomGUILayout.Toggle("Use default PlayerStart?", _target.actFromDefaultPlayerStart, "", "If True, then the camera's position will be relative to the scene's default PlayerStart, rather then the Player's initial position. This ensures that camera movement is the same regardless of where the Player begins in the scene");
                EditorGUILayout.EndVertical();
            }

            UnityVersionHandler.CustomSetDirty(_target);
        }
Beispiel #3
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);
            }
        }
Beispiel #4
0
        public void ShowGUI()
        {
            GUILayout.Label("Basic structure", EditorStyles.boldLabel);

            if (GUILayout.Button("Organise room objects"))
            {
                InitialiseObjects();
            }

            if (AdvGame.GetReferences().settingsManager == null)
            {
                EditorGUILayout.HelpBox("No Settings Manager defined - cannot display full Editor without it!", MessageType.Warning);
                return;
            }

            if (KickStarter.sceneSettings == null)
            {
                return;
            }

            SettingsManager settingsManager = AdvGame.GetReferences().settingsManager;

            EditorGUILayout.BeginHorizontal();
            newFolderName = EditorGUILayout.TextField(newFolderName);

            if (GUILayout.Button("Create new folder", buttonWidth))
            {
                if (newFolderName != "")
                {
                    GameObject newFolder = new GameObject();

                    if (!newFolderName.StartsWith("_"))
                    {
                        newFolder.name = "_" + newFolderName;
                    }
                    else
                    {
                        newFolder.name = newFolderName;
                    }

                    Undo.RegisterCreatedObjectUndo(newFolder, "Create folder " + newFolder.name);

                    if (Selection.activeGameObject)
                    {
                        newFolder.transform.parent = Selection.activeGameObject.transform;
                    }

                    Selection.activeObject = newFolder;
                }
            }
            EditorGUILayout.EndHorizontal();
            EditorGUILayout.Space();

            GUILayout.Label("Scene settings", EditorStyles.boldLabel);
            KickStarter.sceneSettings.navigationMethod = (AC_NavigationMethod)EditorGUILayout.EnumPopup("Pathfinding method:", KickStarter.sceneSettings.navigationMethod);
            KickStarter.navigationManager.ResetEngine();
            if (KickStarter.navigationManager.navigationEngine != null)
            {
                KickStarter.navigationManager.navigationEngine.SceneSettingsGUI();
            }

            if (settingsManager.IsUnity2D() && KickStarter.sceneSettings.navigationMethod != AC_NavigationMethod.PolygonCollider)
            {
                EditorGUILayout.HelpBox("This pathfinding method is not compatible with 'Unity 2D'.", MessageType.Warning);
            }

            EditorGUILayout.BeginHorizontal();
            KickStarter.sceneSettings.defaultPlayerStart = (PlayerStart)EditorGUILayout.ObjectField("Default PlayerStart:", KickStarter.sceneSettings.defaultPlayerStart, typeof(PlayerStart), true);
            if (KickStarter.sceneSettings.defaultPlayerStart == null)
            {
                if (GUILayout.Button("Create", GUILayout.MaxWidth(60f)))
                {
                    PlayerStart newPlayerStart = AddPrefab("Navigation", "PlayerStart", true, false, true).GetComponent <PlayerStart>();
                    newPlayerStart.gameObject.name = "Default PlayerStart";
                    KickStarter.sceneSettings.defaultPlayerStart = newPlayerStart;
                }
            }
            EditorGUILayout.EndHorizontal();
            if (KickStarter.sceneSettings.defaultPlayerStart)
            {
                EditorGUILayout.BeginHorizontal();
                KickStarter.sceneSettings.defaultPlayerStart.cameraOnStart = (_Camera)EditorGUILayout.ObjectField("Default Camera:", KickStarter.sceneSettings.defaultPlayerStart.cameraOnStart, typeof(_Camera), true);
                if (KickStarter.sceneSettings.defaultPlayerStart.cameraOnStart == null)
                {
                    if (GUILayout.Button("Create", GUILayout.MaxWidth(60f)))
                    {
                        if (settingsManager == null || settingsManager.cameraPerspective == CameraPerspective.ThreeD)
                        {
                            GameCamera newCamera = AddPrefab("Camera", "GameCamera", true, false, true).GetComponent <GameCamera>();
                            newCamera.gameObject.name = "NavCam 1";
                            KickStarter.sceneSettings.defaultPlayerStart.cameraOnStart = newCamera;
                        }
                        else if (settingsManager.cameraPerspective == CameraPerspective.TwoD)
                        {
                            GameCamera2D newCamera = AddPrefab("Camera", "GameCamera2D", true, false, true).GetComponent <GameCamera2D>();
                            newCamera.gameObject.name = "NavCam 1";
                            KickStarter.sceneSettings.defaultPlayerStart.cameraOnStart = newCamera;
                        }
                        else if (settingsManager.cameraPerspective == CameraPerspective.TwoPointFiveD)
                        {
                            GameCamera25D newCamera = AddPrefab("Camera", "GameCamera2.5D", true, false, true).GetComponent <GameCamera25D>();
                            newCamera.gameObject.name = "NavCam 1";
                            KickStarter.sceneSettings.defaultPlayerStart.cameraOnStart = newCamera;
                        }
                    }
                }
                EditorGUILayout.EndHorizontal();
            }
            EditorGUILayout.BeginHorizontal();
            KickStarter.sceneSettings.sortingMap = (SortingMap)EditorGUILayout.ObjectField("Default Sorting map:", KickStarter.sceneSettings.sortingMap, typeof(SortingMap), true);
            if (KickStarter.sceneSettings.sortingMap == null)
            {
                if (GUILayout.Button("Create", GUILayout.MaxWidth(60f)))
                {
                    SortingMap newSortingMap = AddPrefab("Navigation", "SortingMap", true, false, true).GetComponent <SortingMap>();
                    newSortingMap.gameObject.name        = "Default SortingMap";
                    KickStarter.sceneSettings.sortingMap = newSortingMap;
                }
            }
            EditorGUILayout.EndHorizontal();
            EditorGUILayout.BeginHorizontal();
            KickStarter.sceneSettings.defaultSound = (Sound)EditorGUILayout.ObjectField("Default Sound prefab:", KickStarter.sceneSettings.defaultSound, typeof(Sound), true);
            if (KickStarter.sceneSettings.defaultSound == null)
            {
                if (GUILayout.Button("Create", GUILayout.MaxWidth(60f)))
                {
                    Sound newSound = AddPrefab("Logic", "Sound", true, false, true).GetComponent <Sound>();
                    newSound.gameObject.name = "Default Sound";
                    KickStarter.sceneSettings.defaultSound = newSound;
                    newSound.playWhilePaused = true;
                }
            }
            EditorGUILayout.EndHorizontal();

            GUILayout.Label("Scene cutscenes", EditorStyles.boldLabel);
            EditorGUILayout.BeginHorizontal();
            KickStarter.sceneSettings.cutsceneOnStart = (Cutscene)EditorGUILayout.ObjectField("On start:", KickStarter.sceneSettings.cutsceneOnStart, typeof(Cutscene), true);
            if (KickStarter.sceneSettings.cutsceneOnStart == null)
            {
                if (GUILayout.Button("Create", GUILayout.MaxWidth(60f)))
                {
                    Cutscene newCutscene = AddPrefab("Logic", "Cutscene", true, false, true).GetComponent <Cutscene>();
                    newCutscene.gameObject.name = "OnStart";
                    KickStarter.sceneSettings.cutsceneOnStart = newCutscene;
                }
            }
            EditorGUILayout.EndHorizontal();
            EditorGUILayout.BeginHorizontal();
            KickStarter.sceneSettings.cutsceneOnLoad = (Cutscene)EditorGUILayout.ObjectField("On load:", KickStarter.sceneSettings.cutsceneOnLoad, typeof(Cutscene), true);
            if (KickStarter.sceneSettings.cutsceneOnLoad == null)
            {
                if (GUILayout.Button("Create", GUILayout.MaxWidth(60f)))
                {
                    Cutscene newCutscene = AddPrefab("Logic", "Cutscene", true, false, true).GetComponent <Cutscene>();
                    newCutscene.gameObject.name = "OnLoad";
                    KickStarter.sceneSettings.cutsceneOnLoad = newCutscene;
                }
            }
            EditorGUILayout.EndHorizontal();
            EditorGUILayout.BeginHorizontal();
            KickStarter.sceneSettings.cutsceneOnVarChange = (Cutscene)EditorGUILayout.ObjectField("On variable change:", KickStarter.sceneSettings.cutsceneOnVarChange, typeof(Cutscene), true);
            if (KickStarter.sceneSettings.cutsceneOnVarChange == null)
            {
                if (GUILayout.Button("Create", GUILayout.MaxWidth(60f)))
                {
                    Cutscene newCutscene = AddPrefab("Logic", "Cutscene", true, false, true).GetComponent <Cutscene>();
                    newCutscene.gameObject.name = "OnVarChange";
                    KickStarter.sceneSettings.cutsceneOnVarChange = newCutscene;
                }
            }
            EditorGUILayout.EndHorizontal();

            EditorGUILayout.Space();

            GUILayout.Label("Visibility", EditorStyles.boldLabel);

            GUILayout.BeginHorizontal();
            GUILayout.Label("Triggers", buttonWidth);
            if (GUILayout.Button("On", EditorStyles.miniButtonLeft))
            {
                SetTriggerVisibility(true);
            }
            if (GUILayout.Button("Off", EditorStyles.miniButtonRight))
            {
                SetTriggerVisibility(false);
            }
            GUILayout.EndHorizontal();

            GUILayout.BeginHorizontal();
            GUILayout.Label("Collision", buttonWidth);
            if (GUILayout.Button("On", EditorStyles.miniButtonLeft))
            {
                SetCollisionVisiblity(true);
            }
            if (GUILayout.Button("Off", EditorStyles.miniButtonRight))
            {
                SetCollisionVisiblity(false);
            }
            GUILayout.EndHorizontal();

            GUILayout.BeginHorizontal();
            GUILayout.Label("Hotspots", buttonWidth);
            if (GUILayout.Button("On", EditorStyles.miniButtonLeft))
            {
                SetHotspotVisibility(true);
            }
            if (GUILayout.Button("Off", EditorStyles.miniButtonRight))
            {
                SetHotspotVisibility(false);
            }
            GUILayout.EndHorizontal();

            GUILayout.BeginHorizontal();
            GUILayout.Label("NavMesh", buttonWidth);
            if (GUILayout.Button("On", EditorStyles.miniButtonLeft))
            {
                KickStarter.navigationManager.navigationEngine.SetVisibility(true);
            }
            if (GUILayout.Button("Off", EditorStyles.miniButtonRight))
            {
                KickStarter.navigationManager.navigationEngine.SetVisibility(false);
            }
            GUILayout.EndHorizontal();

            ListPrefabs();

            if (GUI.changed)
            {
                EditorUtility.SetDirty(KickStarter.sceneSettings);
                EditorUtility.SetDirty(KickStarter.playerMovement);
                if (KickStarter.sceneSettings.defaultPlayerStart)
                {
                    EditorUtility.SetDirty(KickStarter.sceneSettings.defaultPlayerStart);
                }
            }
        }