void OnDrawGizmosSelected()
        {
            if (ProCamera2D == null)
            {
                return;
            }

            var   gameCamera        = ProCamera2D.GetComponent <Camera>();
            var   cameraDimensions  = Utils.GetScreenSizeInWorldCoords(gameCamera, Mathf.Abs(Vector3D(ProCamera2D.transform.localPosition)));
            float cameraDepthOffset = Vector3D(ProCamera2D.transform.localPosition) + Mathf.Abs(Vector3D(ProCamera2D.transform.localPosition)) * Vector3D(ProCamera2D.transform.forward);
            var   cameraCenter      = VectorHVD(Vector3H(transform.position), Vector3V(transform.position), cameraDepthOffset);

            var startCamSize = Application.isPlaying ? _startCamSize : cameraDimensions.y / 2;

            float finalTargetSize;

            if (SetSizeAsMultiplier)
            {
                finalTargetSize = startCamSize / TargetZoom;
            }
            else if (ProCamera2D.GameCamera.orthographic)
            {
                finalTargetSize = TargetZoom;
            }
            else
            {
                finalTargetSize = Mathf.Abs(Application.isPlaying ? _initialCamDepth : Vector3D(ProCamera2D.transform.localPosition)) * Mathf.Tan(TargetZoom * 0.5f * Mathf.Deg2Rad);
            }

            Gizmos.color = EditorPrefsX.GetColor(PrefsData.ZoomTriggerColorKey, PrefsData.ZoomTriggerColorValue);
            Gizmos.color = new Color(Gizmos.color.r, Gizmos.color.g, Gizmos.color.b, 1f);
            Gizmos.DrawWireCube(cameraCenter, VectorHV(finalTargetSize * 2 * ProCamera2D.GameCamera.aspect, finalTargetSize * 2));
        }
        protected override void DrawGizmos()
        {
            base.DrawGizmos();

            Gizmos.color = EditorPrefsX.GetColor(PrefsData.PanEdgesColorKey, PrefsData.PanEdgesColorValue);
            var   gameCamera        = ProCamera2D.GetComponent <Camera>();
            var   cameraDimensions  = gameCamera.orthographic ? Utils.GetScreenSizeInWorldCoords(gameCamera) : Utils.GetScreenSizeInWorldCoords(gameCamera, Mathf.Abs(Vector3D(transform.localPosition)));
            float cameraDepthOffset = Vector3D(ProCamera2D.transform.localPosition) + Mathf.Abs(Vector3D(transform.localPosition)) * Vector3D(ProCamera2D.transform.forward);

            if (UsePanByMoveToEdges)
            {
                Gizmos.DrawWireCube(
                    VectorHVD(Vector3H(ProCamera2D.transform.localPosition), Vector3V(ProCamera2D.transform.localPosition), cameraDepthOffset),
                    VectorHV(cameraDimensions.x * HorizontalPanEdges, cameraDimensions.y * VerticalPanEdges));
            }

            if (UsePanByDrag)
            {
                if (DraggableAreaRect.x != 0 ||
                    DraggableAreaRect.y != 0 ||
                    DraggableAreaRect.width != 1 ||
                    DraggableAreaRect.height != 1)
                {
                    Gizmos.DrawWireCube(
                        VectorHVD(ProCamera2D.transform.localPosition.x + DraggableAreaRect.x * cameraDimensions.x, ProCamera2D.transform.localPosition.y + DraggableAreaRect.y * cameraDimensions.y, cameraDepthOffset),
                        VectorHV(DraggableAreaRect.width * cameraDimensions.x, DraggableAreaRect.height * cameraDimensions.y));
                }
            }
        }
        override protected void DrawGizmos()
        {
            base.DrawGizmos();

            var cameraDimensions = Utils.GetScreenSizeInWorldCoords(ProCamera2D.GameCamera, Mathf.Abs(Vector3D(transform.localPosition)));

            Gizmos.color = EditorPrefsX.GetColor(PrefsData.RailsColorKey, PrefsData.RailsColorValue);

            if (_tempCameraTargets.Count > 0)
            {
                Gizmos.color = Gizmos.color * .7f;
            }

            // Rails nodes
            for (int i = 0; i < RailNodes.Count; i++)
            {
                Gizmos.DrawWireCube(RailNodes[i], cameraDimensions * .01f);
            }

            // Rails path
            if (RailNodes.Count >= 2)
            {
                for (int i = 0; i < RailNodes.Count - 1; i++)
                {
                    Gizmos.DrawLine(RailNodes[i], RailNodes[i + 1]);
                }
            }
        }
Esempio n. 4
0
        override protected void OnDrawGizmos()
        {
            // HACK to prevent Unity bug on startup: http://forum.unity3d.com/threads/screen-position-out-of-view-frustum.9918/
            _drawGizmosCounter++;
            if (_drawGizmosCounter < 5 && UnityEditor.EditorApplication.timeSinceStartup < 60f)
            {
                return;
            }

            base.OnDrawGizmos();

            if (_gizmosDrawingFailed)
            {
                return;
            }

            var cameraDimensions = Utils.GetScreenSizeInWorldCoords(ProCamera2D.GameCamera, Mathf.Abs(Vector3D(transform.localPosition)));

            // Shake influence
            if (_shakePositionSmoothed != Vector3.zero)
            {
                Gizmos.color = EditorPrefsX.GetColor(PrefsData.ShakeInfluenceColorKey, PrefsData.ShakeInfluenceColorValue);
                Utils.DrawArrowForGizmo(ProCamera2D.TargetsMidPoint, _shakePositionSmoothed, .04f * cameraDimensions.y);
            }
        }
Esempio n. 5
0
        protected override void DrawGizmos()
        {
            base.DrawGizmos();

            var   gameCamera        = ProCamera2D.GetComponent <Camera>();
            var   cameraDimensions  = gameCamera.orthographic ? Utils.GetScreenSizeInWorldCoords(gameCamera) : Utils.GetScreenSizeInWorldCoords(gameCamera, Mathf.Abs(Vector3D(transform.position)));
            float cameraDepthOffset = Vector3D(ProCamera2D.transform.localPosition) + Mathf.Abs(Vector3D(transform.localPosition)) * Vector3D(ProCamera2D.transform.forward);

            Gizmos.color = EditorPrefsX.GetColor(PrefsData.CamDistanceColorKey, PrefsData.CamDistanceColorValue);
            if (LimitTopCameraDistance)
            {
                Gizmos.DrawRay(VectorHVD(Vector3H(transform.position) - cameraDimensions.x / 2, Vector3V(transform.position) + (cameraDimensions.y / 2) * MaxTopTargetDistance, cameraDepthOffset), transform.right * cameraDimensions.x);
            }

            if (LimitBottomCameraDistance)
            {
                Gizmos.DrawRay(VectorHVD(Vector3H(transform.position) - cameraDimensions.x / 2, Vector3V(transform.position) - (cameraDimensions.y / 2) * MaxBottomTargetDistance, cameraDepthOffset), transform.right * cameraDimensions.x);
            }

            if (LimitLeftCameraDistance)
            {
                Gizmos.DrawRay(VectorHVD(Vector3H(transform.position) - (cameraDimensions.x / 2) * MaxLeftTargetDistance, Vector3V(transform.position) - cameraDimensions.y / 2, cameraDepthOffset), transform.up * cameraDimensions.y);
            }

            if (LimitRightCameraDistance)
            {
                Gizmos.DrawRay(VectorHVD(Vector3H(transform.position) + (cameraDimensions.x / 2) * MaxRightTargetDistance, Vector3V(transform.position) - cameraDimensions.y / 2, cameraDepthOffset), transform.up * cameraDimensions.y);
            }
        }
Esempio n. 6
0
        override protected void DrawGizmos()
        {
            base.DrawGizmos();

            var   gameCamera        = ProCamera2D.GetComponent <Camera>();
            var   cameraDimensions  = gameCamera.orthographic ? Utils.GetScreenSizeInWorldCoords(gameCamera) : Utils.GetScreenSizeInWorldCoords(gameCamera, Mathf.Abs(Vector3D(transform.localPosition)));
            float cameraDepthOffset = Vector3D(ProCamera2D.transform.localPosition) + Mathf.Abs(Vector3D(transform.localPosition)) * Vector3D(ProCamera2D.transform.forward);

            Gizmos.color = EditorPrefsX.GetColor(PrefsData.NumericBoundariesColorKey, PrefsData.NumericBoundariesColorValue);

            if (UseNumericBoundaries)
            {
                if (UseTopBoundary)
                {
                    Gizmos.DrawRay(VectorHVD(Vector3H(transform.localPosition) - cameraDimensions.x / 2, TopBoundary, cameraDepthOffset), transform.right * cameraDimensions.x);
                }

                if (UseBottomBoundary)
                {
                    Gizmos.DrawRay(VectorHVD(Vector3H(transform.localPosition) - cameraDimensions.x / 2, BottomBoundary, cameraDepthOffset), transform.right * cameraDimensions.x);
                }

                if (UseRightBoundary)
                {
                    Gizmos.DrawRay(VectorHVD(RightBoundary, Vector3V(transform.localPosition) - cameraDimensions.y / 2, cameraDepthOffset), transform.up * cameraDimensions.y);
                }

                if (UseLeftBoundary)
                {
                    Gizmos.DrawRay(VectorHVD(LeftBoundary, Vector3V(transform.localPosition) - cameraDimensions.y / 2, cameraDepthOffset), transform.up * cameraDimensions.y);
                }
            }
        }
        override protected void OnDrawGizmos()
        {
            // HACK to prevent Unity bug on startup: http://forum.unity3d.com/threads/screen-position-out-of-view-frustum.9918/
            _drawGizmosCounter++;
            if (_drawGizmosCounter < 5 && UnityEditor.EditorApplication.timeSinceStartup < 60f)
            {
                return;
            }

            base.OnDrawGizmos();

            if (_gizmosDrawingFailed)
            {
                return;
            }

            var   gameCamera        = ProCamera2D.GetComponent <Camera>();
            var   cameraDimensions  = gameCamera.orthographic ? Utils.GetScreenSizeInWorldCoords(gameCamera) : Utils.GetScreenSizeInWorldCoords(gameCamera, Mathf.Abs(Vector3D(transform.localPosition)));
            float cameraDepthOffset = Vector3D(ProCamera2D.transform.localPosition) + Mathf.Abs(Vector3D(transform.localPosition)) * Vector3D(ProCamera2D.transform.forward);

            // Draw camera window
            Gizmos.color = EditorPrefsX.GetColor(PrefsData.CameraWindowColorKey, PrefsData.CameraWindowColorValue);
            var cameraRect = GetRectAroundTransf(CameraWindowRect, cameraDimensions, transform);

            Gizmos.DrawWireCube(VectorHVD(cameraRect.x + cameraRect.width / 2, cameraRect.y + cameraRect.height / 2, cameraDepthOffset), VectorHV(cameraRect.width, cameraRect.height));
        }
Esempio n. 8
0
        override protected void DrawGizmos()
        {
            base.DrawGizmos();

            var   gameCamera        = ProCamera2D.GetComponent <Camera>();
            var   cameraDimensions  = gameCamera.orthographic ? Utils.GetScreenSizeInWorldCoords(gameCamera) : Utils.GetScreenSizeInWorldCoords(gameCamera, Mathf.Abs(Vector3D(transform.localPosition)));
            float cameraDepthOffset = Vector3D(ProCamera2D.transform.localPosition) + Mathf.Abs(Vector3D(transform.localPosition)) * Vector3D(ProCamera2D.transform.forward);
            var   cameraCenter      = VectorHVD(Vector3H(transform.position), Vector3V(transform.position), cameraDepthOffset);

            Gizmos.color = EditorPrefsX.GetColor(PrefsData.ForwardFocusColorKey, PrefsData.ForwardFocusColorValue);

            if (LeftFocus > EPSILON)
            {
                Gizmos.DrawRay(VectorHVD(Vector3H(transform.position) + cameraDimensions.x * LeftFocus, Vector3V(transform.position) - cameraDimensions.y / 2, cameraDepthOffset), transform.up * cameraDimensions.y);
                Utils.DrawArrowForGizmo(cameraCenter + VectorHV(cameraDimensions.x * LeftFocus, 0), -transform.right * .3f);
            }

            if (RightFocus > EPSILON)
            {
                Gizmos.DrawRay(VectorHVD(Vector3H(transform.position) - cameraDimensions.x * RightFocus, Vector3V(transform.position) - cameraDimensions.y / 2, cameraDepthOffset), transform.up * cameraDimensions.y);
                Utils.DrawArrowForGizmo(cameraCenter - VectorHV(cameraDimensions.x * RightFocus, 0), transform.right * .3f);
            }

            if (TopFocus > EPSILON)
            {
                Gizmos.DrawRay(VectorHVD(Vector3H(transform.position) - cameraDimensions.x / 2, Vector3V(transform.position) - cameraDimensions.y * TopFocus, cameraDepthOffset), transform.right * cameraDimensions.x);
                Utils.DrawArrowForGizmo(cameraCenter - VectorHV(0, cameraDimensions.y * TopFocus), transform.up * .3f);
            }

            if (BottomFocus > EPSILON)
            {
                Gizmos.DrawRay(VectorHVD(Vector3H(transform.position) - cameraDimensions.x / 2, Vector3V(transform.position) + cameraDimensions.y * BottomFocus, cameraDepthOffset), transform.right * cameraDimensions.x);
                Utils.DrawArrowForGizmo(cameraCenter + VectorHV(0, cameraDimensions.y * BottomFocus), -transform.up * .3f);
            }
        }
Esempio n. 9
0
        override protected void OnDrawGizmos()
        {
            base.OnDrawGizmos();

            if (_gizmosDrawingFailed)
            {
                return;
            }

            float cameraDepthOffset = Vector3D(ProCamera2D.transform.localPosition) + Mathf.Abs(Vector3D(ProCamera2D.transform.localPosition)) * Vector3D(ProCamera2D.transform.forward);
            var   cameraCenter      = VectorHVD(Vector3H(transform.position), Vector3V(transform.position), cameraDepthOffset);

            Gizmos.color = EditorPrefsX.GetColor(PrefsData.TriggerShapeColorKey, PrefsData.TriggerShapeColorValue);

            if (TriggerShape == TriggerShape.RECTANGLE)
            {
                Gizmos.DrawWireCube(cameraCenter, VectorHVD(Vector3H(transform.localScale), Vector3V(transform.localScale), 0f));

                if (_exclusiveInfluencePercentage > 0)
                {
                    Gizmos.DrawWireCube(cameraCenter, VectorHVD(Vector3H(transform.localScale) * _exclusiveInfluencePercentage, Vector3V(transform.localScale) * _exclusiveInfluencePercentage, 0f));
                }
            }
            else
            {
                Gizmos.DrawWireSphere(cameraCenter, ((Vector3H(transform.localScale) + Vector3V(transform.localScale)) * .25f));

                if (_exclusiveInfluencePercentage > 0)
                {
                    Gizmos.DrawWireSphere(cameraCenter, ((Vector3H(transform.localScale) + Vector3V(transform.localScale)) * .25f) * _exclusiveInfluencePercentage);
                }
            }
        }
Esempio n. 10
0
        static void PreferencesGUI()
        {
            // Load the preferences
            if (!_prefsLoaded)
            {
                _procamera2DGizmosColors = new Color[_procamera2DGizmosKeys.Length];
                for (int i = 0; i < _procamera2DGizmosColors.Length; i++)
                {
                    _procamera2DGizmosColors[i] = EditorPrefsX.GetColor(_procamera2DGizmosKeys[i], _procamera2DGizmosValues[i]);
                }

                _prefsLoaded = true;
            }

            // Preferences GUI
            _scrollPos = EditorGUILayout.BeginScrollView(_scrollPos);

            GUILayout.Label("ProCamera2D", EditorStyles.boldLabel);
            for (int i = 0; i < _procamera2DGizmosColors.Length; i++)
            {
                _procamera2DGizmosColors[i] = EditorGUILayout.ColorField(_procamera2DGizmosKeys[i], _procamera2DGizmosColors[i]);

                if (i == 9)
                {
                    EditorGUILayout.Space();
                    GUILayout.Label("Plugins", EditorStyles.boldLabel);
                }

                if (i == 11)
                {
                    EditorGUILayout.Space();
                    GUILayout.Label("Helpers", EditorStyles.boldLabel);
                }
            }

            // Reset defaults
            EditorGUILayout.Space();
            EditorGUILayout.Space();
            if (GUILayout.Button("Use defaults", GUILayout.Width(120)))
            {
                for (int i = 0; i < _procamera2DGizmosColors.Length; i++)
                {
                    EditorPrefsX.SetColor(_procamera2DGizmosKeys[i], _procamera2DGizmosValues[i]);
                }
            }

            EditorGUILayout.EndScrollView();

            // Save the preferences
            if (GUI.changed)
            {
                for (int i = 0; i < _procamera2DGizmosColors.Length; i++)
                {
                    EditorPrefsX.SetColor(_procamera2DGizmosKeys[i], _procamera2DGizmosColors[i]);
                }
            }
        }
Esempio n. 11
0
        override protected void DrawGizmos()
        {
            base.DrawGizmos();

            var cameraDimensions = Utils.GetScreenSizeInWorldCoords(ProCamera2D.GameCamera, Mathf.Abs(Vector3D(transform.localPosition)));

            if (Application.isPlaying && _shakeParent.localPosition != Vector3.zero)
            {
                Gizmos.color = EditorPrefsX.GetColor(PrefsData.ShakeInfluenceColorKey, PrefsData.ShakeInfluenceColorValue);
                Utils.DrawArrowForGizmo(ProCamera2D.TargetsMidPoint, _shakeParent.localPosition, .04f * cameraDimensions.y);
            }
        }
Esempio n. 12
0
        override protected void OnDrawGizmos()
        {
            base.OnDrawGizmos();

            if (_gizmosDrawingFailed)
            {
                return;
            }

            float cameraDepthOffset = Vector3D(ProCamera2D.transform.localPosition) + Mathf.Abs(Vector3D(ProCamera2D.transform.localPosition)) * Vector3D(ProCamera2D.transform.forward);
            var   cameraCenter      = VectorHVD(Vector3H(transform.position), Vector3V(transform.position), cameraDepthOffset);

            Gizmos.color = EditorPrefsX.GetColor(PrefsData.TriggerShapeColorKey, PrefsData.TriggerShapeColorValue);

            if (TriggerShape == TriggerShape.RECTANGLE)
            {
                Gizmos.DrawWireCube(cameraCenter, VectorHVD(Vector3H(transform.localScale), Vector3V(transform.localScale), 0f));

                if (_exclusiveInfluencePercentage > 0)
                {
                    Gizmos.DrawWireCube(cameraCenter, VectorHVD(Vector3H(transform.localScale) * _exclusiveInfluencePercentage, Vector3V(transform.localScale) * _exclusiveInfluencePercentage, 0f));
                }
            }
            else
            {
                var axis = Vector3.zero;
                switch (ProCamera2D.Axis)
                {
                case MovementAxis.XY:
                    axis = new Vector3(1f, 1f, 0f);
                    break;

                case MovementAxis.XZ:
                    axis = new Vector3(1f, 0f, 1f);
                    break;

                case MovementAxis.YZ:
                    axis = new Vector3(0f, 1f, 1f);
                    break;
                }

                Gizmos.matrix = Matrix4x4.TRS(cameraCenter, Quaternion.identity, axis);
                Gizmos.DrawWireSphere(Vector3.zero, ((Vector3H(transform.localScale) + Vector3V(transform.localScale)) * .25f));

                if (_exclusiveInfluencePercentage > 0)
                {
                    Gizmos.DrawWireSphere(Vector3.zero, ((Vector3H(transform.localScale) + Vector3V(transform.localScale)) * .25f) * _exclusiveInfluencePercentage);
                }

                Gizmos.matrix = Matrix4x4.identity;
            }
        }
        override protected void DrawGizmos()
        {
            base.DrawGizmos();

            var   gameCamera        = ProCamera2D.GetComponent <Camera>();
            var   cameraDimensions  = gameCamera.orthographic ? Utils.GetScreenSizeInWorldCoords(gameCamera) : Utils.GetScreenSizeInWorldCoords(gameCamera, Mathf.Abs(Vector3D(transform.localPosition)));
            float cameraDepthOffset = Vector3D(ProCamera2D.transform.localPosition) + Mathf.Abs(Vector3D(transform.localPosition)) * Vector3D(ProCamera2D.transform.forward);

            // Draw camera window
            Gizmos.color = EditorPrefsX.GetColor(PrefsData.CameraWindowColorKey, PrefsData.CameraWindowColorValue);
            var cameraRect = GetRectAroundTransf(CameraWindowRect, cameraDimensions, transform);

            Gizmos.DrawWireCube(VectorHVD(cameraRect.x + cameraRect.width / 2, cameraRect.y + cameraRect.height / 2, cameraDepthOffset), VectorHV(cameraRect.width, cameraRect.height));
        }
        override protected void DrawGizmos()
        {
            base.DrawGizmos();

            var   gameCamera        = ProCamera2D.GetComponent <Camera>();
            var   cameraDimensions  = gameCamera.orthographic ? Utils.GetScreenSizeInWorldCoords(gameCamera) : Utils.GetScreenSizeInWorldCoords(gameCamera, Mathf.Abs(Vector3D(transform.localPosition)));
            float cameraDepthOffset = Vector3D(ProCamera2D.transform.localPosition) + Mathf.Abs(Vector3D(transform.localPosition)) * Vector3D(ProCamera2D.transform.forward);
            var   cameraCenter      = Application.isPlaying ? ProCamera2D.TargetsMidPoint : VectorHVD(Vector3H(transform.position), Vector3V(transform.position), cameraDepthOffset);

            var bordersColor = DisableWhenOneTarget && ProCamera2D.CameraTargets.Count <= 1 ? EditorPrefsX.GetColor(PrefsData.ZoomToFitColorKey, Color.white) * .75f : EditorPrefsX.GetColor(PrefsData.ZoomToFitColorKey, Color.white);

            // Targets bounding box
            if (Application.isPlaying && ProCamera2D.CameraTargets.Count > 1)
            {
                float maxX = Mathf.NegativeInfinity;
                float minX = Mathf.Infinity;
                float maxY = Mathf.NegativeInfinity;
                float minY = Mathf.Infinity;
                for (int i = 0; i < ProCamera2D.CameraTargets.Count; i++)
                {
                    var targetPos = new Vector2(Vector3H(ProCamera2D.CameraTargets[i].TargetPosition) + ProCamera2D.CameraTargets[i].TargetOffset.x, Vector3V(ProCamera2D.CameraTargets[i].TargetPosition) + ProCamera2D.CameraTargets[i].TargetOffset.y);

                    maxX = targetPos.x > maxX ? targetPos.x : maxX;
                    minX = targetPos.x < minX ? targetPos.x : minX;
                    maxY = targetPos.y > maxY ? targetPos.y : maxY;
                    minY = targetPos.y < minY ? targetPos.y : minY;
                }

                Gizmos.color = EditorPrefsX.GetColor(PrefsData.ZoomToFitColorKey, Color.white) * .25f;
                Gizmos.DrawWireCube(cameraCenter, VectorHV(maxX - minX, maxY - minY));
            }

            if (CompensateForCameraPosition)
            {
                cameraCenter = VectorHVD(Vector3H(ProCamera2D.transform.localPosition), Vector3V(ProCamera2D.transform.localPosition), cameraDepthOffset);
            }

            // Zoom out border
            Gizmos.color = Math.Abs(_targetCamSizeSmoothed - _maxCameraSize) < .01f ? bordersColor * .5f : bordersColor;
            Gizmos.DrawWireCube(cameraCenter, VectorHV(cameraDimensions.x, cameraDimensions.y) * ZoomOutBorder);
            Utils.DrawArrowForGizmo(cameraCenter + VectorHV(cameraDimensions.x / 2 * ZoomOutBorder, cameraDimensions.y / 2 * ZoomOutBorder), VectorHV(.05f * cameraDimensions.y, .05f * cameraDimensions.y), .04f * cameraDimensions.y);
            Utils.DrawArrowForGizmo(cameraCenter - VectorHV(cameraDimensions.x / 2 * ZoomOutBorder, cameraDimensions.y / 2 * ZoomOutBorder), VectorHV(-.05f * cameraDimensions.y, -.05f * cameraDimensions.y), .04f * cameraDimensions.y);

            // Zoom in border
            Gizmos.color = Math.Abs(_targetCamSizeSmoothed - _minCameraSize) < .01f ? bordersColor * .75f : bordersColor;
            Gizmos.DrawWireCube(cameraCenter, VectorHV(cameraDimensions.x, cameraDimensions.y) * ZoomInBorder);
            Utils.DrawArrowForGizmo(cameraCenter + VectorHV(cameraDimensions.x / 2 * ZoomInBorder, cameraDimensions.y / 2 * ZoomInBorder), VectorHV(-.05f * cameraDimensions.y, -.05f * cameraDimensions.y), .04f * cameraDimensions.y);
            Utils.DrawArrowForGizmo(cameraCenter - VectorHV(cameraDimensions.x / 2 * ZoomInBorder, cameraDimensions.y / 2 * ZoomInBorder), VectorHV(.05f * cameraDimensions.y, .05f * cameraDimensions.y), .04f * cameraDimensions.y);
        }
Esempio n. 15
0
        override protected void OnDrawGizmos()
        {
            // HACK to prevent Unity bug on startup: http://forum.unity3d.com/threads/screen-position-out-of-view-frustum.9918/
            _drawGizmosCounter++;
            if (_drawGizmosCounter < 5 && UnityEditor.EditorApplication.timeSinceStartup < 60f)
            {
                return;
            }

            base.OnDrawGizmos();

            if (_gizmosDrawingFailed)
            {
                return;
            }

            var   gameCamera        = ProCamera2D.GetComponent <Camera>();
            var   cameraDimensions  = gameCamera.orthographic ? Utils.GetScreenSizeInWorldCoords(gameCamera) : Utils.GetScreenSizeInWorldCoords(gameCamera, Mathf.Abs(Vector3D(transform.localPosition)));
            float cameraDepthOffset = Vector3D(ProCamera2D.transform.localPosition) + Mathf.Abs(Vector3D(transform.localPosition)) * Vector3D(ProCamera2D.transform.forward);
            var   cameraCenter      = VectorHVD(Vector3H(transform.position), Vector3V(transform.position), cameraDepthOffset);

            Gizmos.color = EditorPrefsX.GetColor(PrefsData.ForwardFocusColorKey, PrefsData.ForwardFocusColorValue);

            if (LeftFocus > EPSILON)
            {
                Gizmos.DrawRay(VectorHVD(Vector3H(transform.position) + cameraDimensions.x * LeftFocus, Vector3V(transform.position) - cameraDimensions.y / 2, cameraDepthOffset), transform.up * cameraDimensions.y);
                Utils.DrawArrowForGizmo(cameraCenter + VectorHV(cameraDimensions.x * LeftFocus, 0), -transform.right * .3f);
            }

            if (RightFocus > EPSILON)
            {
                Gizmos.DrawRay(VectorHVD(Vector3H(transform.position) - cameraDimensions.x * RightFocus, Vector3V(transform.position) - cameraDimensions.y / 2, cameraDepthOffset), transform.up * cameraDimensions.y);
                Utils.DrawArrowForGizmo(cameraCenter - VectorHV(cameraDimensions.x * RightFocus, 0), transform.right * .3f);
            }

            if (TopFocus > EPSILON)
            {
                Gizmos.DrawRay(VectorHVD(Vector3H(transform.position) - cameraDimensions.x / 2, Vector3V(transform.position) - cameraDimensions.y * TopFocus, cameraDepthOffset), transform.right * cameraDimensions.x);
                Utils.DrawArrowForGizmo(cameraCenter - VectorHV(0, cameraDimensions.y * TopFocus), transform.up * .3f);
            }

            if (BottomFocus > EPSILON)
            {
                Gizmos.DrawRay(VectorHVD(Vector3H(transform.position) - cameraDimensions.x / 2, Vector3V(transform.position) + cameraDimensions.y * BottomFocus, cameraDepthOffset), transform.right * cameraDimensions.x);
                Utils.DrawArrowForGizmo(cameraCenter + VectorHV(0, cameraDimensions.y * BottomFocus), -transform.up * .3f);
            }
        }
        override protected void OnDrawGizmos()
        {
            // HACK to prevent Unity bug on startup: http://forum.unity3d.com/threads/screen-position-out-of-view-frustum.9918/
            _drawGizmosCounter++;
            if (_drawGizmosCounter < 5 && UnityEditor.EditorApplication.timeSinceStartup < 60f)
            {
                return;
            }

            base.OnDrawGizmos();

            if (_gizmosDrawingFailed)
            {
                return;
            }

            var   gameCamera        = ProCamera2D.GetComponent <Camera>();
            var   cameraDimensions  = gameCamera.orthographic ? Utils.GetScreenSizeInWorldCoords(gameCamera) : Utils.GetScreenSizeInWorldCoords(gameCamera, Mathf.Abs(Vector3D(transform.localPosition)));
            float cameraDepthOffset = Vector3D(ProCamera2D.transform.localPosition) + Mathf.Abs(Vector3D(transform.localPosition)) * Vector3D(ProCamera2D.transform.forward);

            // Numeric boundaries
            Gizmos.color = EditorPrefsX.GetColor(PrefsData.NumericBoundariesColorKey, PrefsData.NumericBoundariesColorValue);

            if (UseNumericBoundaries)
            {
                if (UseTopBoundary)
                {
                    Gizmos.DrawRay(VectorHVD(Vector3H(transform.localPosition) - cameraDimensions.x / 2, TopBoundary, cameraDepthOffset), transform.right * cameraDimensions.x);
                }

                if (UseBottomBoundary)
                {
                    Gizmos.DrawRay(VectorHVD(Vector3H(transform.localPosition) - cameraDimensions.x / 2, BottomBoundary, cameraDepthOffset), transform.right * cameraDimensions.x);
                }

                if (UseRightBoundary)
                {
                    Gizmos.DrawRay(VectorHVD(RightBoundary, Vector3V(transform.localPosition) - cameraDimensions.y / 2, cameraDepthOffset), transform.up * cameraDimensions.y);
                }

                if (UseLeftBoundary)
                {
                    Gizmos.DrawRay(VectorHVD(LeftBoundary, Vector3V(transform.localPosition) - cameraDimensions.y / 2, cameraDepthOffset), transform.up * cameraDimensions.y);
                }
            }
        }
Esempio n. 17
0
        void OnDrawGizmosSelected()
        {
            // HACK to prevent Unity bug on startup: http://forum.unity3d.com/threads/screen-position-out-of-view-frustum.9918/
            _drawGizmosCounter++;
            if (_drawGizmosCounter < 5 && UnityEditor.EditorApplication.timeSinceStartup < 60f)
            {
                return;
            }

            if (_gizmosDrawingFailed)
            {
                return;
            }

            float cameraDepthOffset = Vector3D(ProCamera2D.transform.localPosition) + Mathf.Abs(Vector3D(ProCamera2D.transform.localPosition)) * Vector3D(ProCamera2D.transform.forward);
            var   cameraCenter      = VectorHVD(Vector3H(transform.position), Vector3V(transform.position), cameraDepthOffset);
            var   cameraDimensions  = Utils.GetScreenSizeInWorldCoords(ProCamera2D.GetComponent <Camera>(), Mathf.Abs(Vector3D(ProCamera2D.transform.localPosition)));

            GetTargetBoundaries();

            Gizmos.color = EditorPrefsX.GetColor(PrefsData.BoundariesTriggerColorKey, PrefsData.BoundariesTriggerColorValue);
            if (UseTopBoundary)
            {
                Gizmos.DrawRay(VectorHVD(Vector3H(transform.position) - cameraDimensions.x / 2, _targetTopBoundary, cameraDepthOffset), ProCamera2D.transform.right * cameraDimensions.x);
                Utils.DrawArrowForGizmo(cameraCenter, VectorHV(0, _targetTopBoundary - Vector3V(transform.position)));
            }

            if (UseBottomBoundary)
            {
                Gizmos.DrawRay(VectorHVD(Vector3H(transform.position) - cameraDimensions.x / 2, _targetBottomBoundary, cameraDepthOffset), ProCamera2D.transform.right * cameraDimensions.x);
                Utils.DrawArrowForGizmo(cameraCenter, VectorHV(0, _targetBottomBoundary - Vector3V(transform.position)));
            }

            if (UseRightBoundary)
            {
                Gizmos.DrawRay(VectorHVD(_targetRightBoundary, Vector3V(transform.position) - cameraDimensions.y / 2, cameraDepthOffset), ProCamera2D.transform.up * cameraDimensions.y);
                Utils.DrawArrowForGizmo(cameraCenter, VectorHV(_targetRightBoundary - Vector3H(transform.position), 0));
            }

            if (UseLeftBoundary)
            {
                Gizmos.DrawRay(VectorHVD(_targetLeftBoundary, Vector3V(transform.position) - cameraDimensions.y / 2, cameraDepthOffset), ProCamera2D.transform.up * cameraDimensions.y);
                Utils.DrawArrowForGizmo(cameraCenter, VectorHV(_targetLeftBoundary - Vector3H(transform.position), 0));
            }
        }
Esempio n. 18
0
        void OnDrawGizmosSelected()
        {
            // HACK to prevent Unity bug on startup: http://forum.unity3d.com/threads/screen-position-out-of-view-frustum.9918/
            _drawGizmosCounter++;
            if (_drawGizmosCounter < 5 && UnityEditor.EditorApplication.timeSinceStartup < 60f)
            {
                return;
            }

            if (_gizmosDrawingFailed)
            {
                return;
            }

            var   gameCamera        = ProCamera2D.GetComponent <Camera>();
            var   cameraDimensions  = Utils.GetScreenSizeInWorldCoords(gameCamera, Mathf.Abs(Vector3D(ProCamera2D.transform.localPosition)));
            float cameraDepthOffset = Vector3D(ProCamera2D.transform.localPosition) + Mathf.Abs(Vector3D(ProCamera2D.transform.localPosition)) * Vector3D(ProCamera2D.transform.forward);
            var   cameraCenter      = VectorHVD(Vector3H(transform.position), Vector3V(transform.position), cameraDepthOffset);

            var startCamSize = Application.isPlaying ? _startCamSize : cameraDimensions.y / 2;

            float finalTargetSize;

            if (SetSizeAsMultiplier)
            {
                finalTargetSize = startCamSize / TargetZoom;
            }
            else if (ProCamera2D.GameCamera.orthographic)
            {
                finalTargetSize = TargetZoom;
            }
            else
            {
                finalTargetSize = Mathf.Abs(Application.isPlaying ? _initialCamDepth : Vector3D(ProCamera2D.transform.localPosition)) * Mathf.Tan(TargetZoom * 0.5f * Mathf.Deg2Rad);
            }

            Gizmos.color = EditorPrefsX.GetColor(PrefsData.ZoomTriggerColorKey, PrefsData.ZoomTriggerColorValue);
            Gizmos.color = new Color(Gizmos.color.r, Gizmos.color.g, Gizmos.color.b, 1f);
            Gizmos.DrawWireCube(cameraCenter, VectorHV(finalTargetSize * 2 * ProCamera2D.GameCamera.aspect, finalTargetSize * 2));
        }
Esempio n. 19
0
        override protected void OnDrawGizmos()
        {
            // HACK to prevent Unity bug on startup: http://forum.unity3d.com/threads/screen-position-out-of-view-frustum.9918/
            _drawGizmosCounter++;
            if (_drawGizmosCounter < 5 && UnityEditor.EditorApplication.timeSinceStartup < 60f)
            {
                return;
            }

            base.OnDrawGizmos();

            if (_gizmosDrawingFailed)
            {
                return;
            }

            var cameraDimensions = Utils.GetScreenSizeInWorldCoords(ProCamera2D.GameCamera, Mathf.Abs(Vector3D(transform.localPosition)));

            Gizmos.color = EditorPrefsX.GetColor(PrefsData.RailsColorKey, PrefsData.RailsColorValue);

            if (_tempCameraTargets.Count > 0)
            {
                Gizmos.color = Gizmos.color * .7f;
            }

            // Rails nodes
            for (int i = 0; i < RailNodes.Count; i++)
            {
                Gizmos.DrawWireCube(RailNodes[i], cameraDimensions * .01f);
            }

            // Rails path
            if (RailNodes.Count >= 2)
            {
                for (int i = 0; i < RailNodes.Count - 1; i++)
                {
                    Gizmos.DrawLine(RailNodes[i], RailNodes[i + 1]);
                }
            }
        }
        void OnDrawGizmosSelected()
        {
            if (ProCamera2D == null)
            {
                return;
            }

            float cameraDepthOffset = Vector3D(ProCamera2D.transform.localPosition) + Mathf.Abs(Vector3D(ProCamera2D.transform.localPosition)) * Vector3D(ProCamera2D.transform.forward);
            var   cameraCenter      = VectorHVD(Vector3H(transform.position), Vector3V(transform.position), cameraDepthOffset);
            var   cameraDimensions  = Utils.GetScreenSizeInWorldCoords(ProCamera2D.GetComponent <Camera>(), Mathf.Abs(Vector3D(ProCamera2D.transform.localPosition)));

            GetTargetBoundaries();

            Gizmos.color = EditorPrefsX.GetColor(PrefsData.BoundariesTriggerColorKey, PrefsData.BoundariesTriggerColorValue);
            if (UseTopBoundary)
            {
                Gizmos.DrawRay(VectorHVD(Vector3H(transform.position) - cameraDimensions.x / 2, _targetTopBoundary, cameraDepthOffset), ProCamera2D.transform.right * cameraDimensions.x);
                Utils.DrawArrowForGizmo(cameraCenter, VectorHV(0, _targetTopBoundary - Vector3V(transform.position)));
            }

            if (UseBottomBoundary)
            {
                Gizmos.DrawRay(VectorHVD(Vector3H(transform.position) - cameraDimensions.x / 2, _targetBottomBoundary, cameraDepthOffset), ProCamera2D.transform.right * cameraDimensions.x);
                Utils.DrawArrowForGizmo(cameraCenter, VectorHV(0, _targetBottomBoundary - Vector3V(transform.position)));
            }

            if (UseRightBoundary)
            {
                Gizmos.DrawRay(VectorHVD(_targetRightBoundary, Vector3V(transform.position) - cameraDimensions.y / 2, cameraDepthOffset), ProCamera2D.transform.up * cameraDimensions.y);
                Utils.DrawArrowForGizmo(cameraCenter, VectorHV(_targetRightBoundary - Vector3H(transform.position), 0));
            }

            if (UseLeftBoundary)
            {
                Gizmos.DrawRay(VectorHVD(_targetLeftBoundary, Vector3V(transform.position) - cameraDimensions.y / 2, cameraDepthOffset), ProCamera2D.transform.up * cameraDimensions.y);
                Utils.DrawArrowForGizmo(cameraCenter, VectorHV(_targetLeftBoundary - Vector3H(transform.position), 0));
            }
        }
Esempio n. 21
0
        override protected void DrawGizmos()
        {
            base.DrawGizmos();

            UnityEditor.Handles.color = EditorPrefsX.GetColor(PrefsData.RoomsColorKey, PrefsData.RoomsColorValue);

            for (int i = 0; i < Rooms.Count; i++)
            {
                // Room border
                var rect = Rooms[i].Dimensions;
                rect.x -= rect.width / 2f - (UseRelativePosition ? transform.position.x : 0);
                rect.y -= rect.height / 2f - (UseRelativePosition ? transform.position.y : 0);
                Vector3[] rectangleCorners =
                {
                    VectorHVD(rect.position.x,              rect.position.y, 0),                     // Bottom Left
                    VectorHVD(rect.position.x + rect.width, rect.position.y, 0),                     // Bottom Right
                    VectorHVD(rect.position.x + rect.width, rect.position.y + rect.height, 0),       // Top Right
                    VectorHVD(rect.position.x,              rect.position.y + rect.height, 0)        // Top Left
                };

                UnityEditor.Handles.DrawSolidRectangleWithOutline(rectangleCorners, Color.clear, Color.white);
            }
        }
Esempio n. 22
0
        override protected void OnDrawGizmos()
        {
            // HACK to prevent Unity bug on startup: http://forum.unity3d.com/threads/screen-position-out-of-view-frustum.9918/
            _drawGizmosCounter++;
            if (_drawGizmosCounter < 5 && UnityEditor.EditorApplication.timeSinceStartup < 60f)
            {
                return;
            }

            base.OnDrawGizmos();

            if (_gizmosDrawingFailed)
            {
                return;
            }

            var   gameCamera        = ProCamera2D.GetComponent <Camera>();
            var   cameraDimensions  = gameCamera.orthographic ? Utils.GetScreenSizeInWorldCoords(gameCamera) : Utils.GetScreenSizeInWorldCoords(gameCamera, Mathf.Abs(Vector3D(transform.localPosition)));
            float cameraDepthOffset = Vector3D(ProCamera2D.transform.localPosition) + Mathf.Abs(Vector3D(transform.localPosition)) * Vector3D(ProCamera2D.transform.forward);
            var   cameraCenter      = VectorHVD(Vector3H(transform.position), Vector3V(transform.position), cameraDepthOffset);


            var bordersColor = DisableWhenOneTarget && ProCamera2D.CameraTargets.Count <= 1 ? PrefsData.ZoomToFitColorValue * .75f : PrefsData.ZoomToFitColorValue;

            // Zoom out border
            Gizmos.color = Math.Abs(_targetCamSizeSmoothed - _maxCameraSize) < .01f ? Color.red : EditorPrefsX.GetColor(PrefsData.ZoomToFitColorKey, bordersColor);
            Gizmos.DrawWireCube(cameraCenter, VectorHV(cameraDimensions.x, cameraDimensions.y) * ZoomOutBorder);
            Utils.DrawArrowForGizmo(cameraCenter + VectorHV(cameraDimensions.x / 2 * ZoomOutBorder, cameraDimensions.y / 2 * ZoomOutBorder), VectorHV(.05f * cameraDimensions.y, .05f * cameraDimensions.y), .04f * cameraDimensions.y);
            Utils.DrawArrowForGizmo(cameraCenter - VectorHV(cameraDimensions.x / 2 * ZoomOutBorder, cameraDimensions.y / 2 * ZoomOutBorder), VectorHV(-.05f * cameraDimensions.y, -.05f * cameraDimensions.y), .04f * cameraDimensions.y);

            // Zoom in border
            Gizmos.color = Math.Abs(_targetCamSizeSmoothed - _minCameraSize) < .01f ? Color.red : EditorPrefsX.GetColor(PrefsData.ZoomToFitColorKey, bordersColor);
            Gizmos.DrawWireCube(cameraCenter, VectorHV(cameraDimensions.x, cameraDimensions.y) * ZoomInBorder);
            Utils.DrawArrowForGizmo(cameraCenter + VectorHV(cameraDimensions.x / 2 * ZoomInBorder, cameraDimensions.y / 2 * ZoomInBorder), VectorHV(-.05f * cameraDimensions.y, -.05f * cameraDimensions.y), .04f * cameraDimensions.y);
            Utils.DrawArrowForGizmo(cameraCenter - VectorHV(cameraDimensions.x / 2 * ZoomInBorder, cameraDimensions.y / 2 * ZoomInBorder), VectorHV(.05f * cameraDimensions.y, .05f * cameraDimensions.y), .04f * cameraDimensions.y);
        }
Esempio n. 23
0
        void OnDrawGizmos()
        {
            // HACK to prevent Unity bug on startup: http://forum.unity3d.com/threads/screen-position-out-of-view-frustum.9918/
            _drawGizmosCounter++;
            if (_drawGizmosCounter < 5 && UnityEditor.EditorApplication.timeSinceStartup < 60f)
            {
                return;
            }

            switch (Axis)
            {
            case MovementAxis.XY:
                Vector3H  = vector => vector.x;
                Vector3V  = vector => vector.y;
                Vector3D  = vector => vector.z;
                VectorHV  = (h, v) => new Vector3(h, v, 0);
                VectorHVD = (h, v, d) => new Vector3(h, v, d);
                break;

            case MovementAxis.XZ:
                Vector3H  = vector => vector.x;
                Vector3V  = vector => vector.z;
                Vector3D  = vector => vector.y;
                VectorHV  = (h, v) => new Vector3(h, 0, v);
                VectorHVD = (h, v, d) => new Vector3(h, d, v);
                break;

            case MovementAxis.YZ:
                Vector3H  = vector => vector.z;
                Vector3V  = vector => vector.y;
                Vector3D  = vector => vector.x;
                VectorHV  = (h, v) => new Vector3(0, v, h);
                VectorHVD = (h, v, d) => new Vector3(d, v, h);
                break;
            }

            var gameCamera = GetComponent <Camera>();

            // Don't draw gizmos on other cameras
            if (Camera.current != gameCamera &&
                ((UnityEditor.SceneView.lastActiveSceneView != null && Camera.current != UnityEditor.SceneView.lastActiveSceneView.camera) ||
                 (UnityEditor.SceneView.lastActiveSceneView == null)))
            {
                return;
            }

            var   cameraDimensions  = Utils.GetScreenSizeInWorldCoords(gameCamera, Mathf.Abs(Vector3D(transform.localPosition)));
            float cameraDepthOffset = Vector3D(transform.localPosition) + Mathf.Abs(Vector3D(transform.localPosition)) * Vector3D(transform.forward);

            // Numeric boundaries
            Gizmos.color = EditorPrefsX.GetColor(PrefsData.NumericBoundariesColorKey, PrefsData.NumericBoundariesColorValue);
            if (UseNumericBoundaries)
            {
                if (UseTopBoundary)
                {
                    Gizmos.DrawRay(VectorHVD(Vector3H(transform.localPosition) - cameraDimensions.x / 2, TopBoundary, cameraDepthOffset), transform.right * cameraDimensions.x);
                }

                if (UseBottomBoundary)
                {
                    Gizmos.DrawRay(VectorHVD(Vector3H(transform.localPosition) - cameraDimensions.x / 2, BottomBoundary, cameraDepthOffset), transform.right * cameraDimensions.x);
                }

                if (UseRightBoundary)
                {
                    Gizmos.DrawRay(VectorHVD(RightBoundary, Vector3V(transform.localPosition) - cameraDimensions.y / 2, cameraDepthOffset), transform.up * cameraDimensions.y);
                }

                if (UseLeftBoundary)
                {
                    Gizmos.DrawRay(VectorHVD(LeftBoundary, Vector3V(transform.localPosition) - cameraDimensions.y / 2, cameraDepthOffset), transform.up * cameraDimensions.y);
                }
            }

            // Targets mid point
            Gizmos.color = EditorPrefsX.GetColor(PrefsData.TargetsMidPointColorKey, PrefsData.TargetsMidPointColorValue);
            var targetsMidPoint = GetTargetsWeightedMidPoint(CameraTargets);

            targetsMidPoint = VectorHVD(Vector3H(targetsMidPoint), Vector3V(targetsMidPoint), cameraDepthOffset);
            Gizmos.DrawWireSphere(targetsMidPoint, .01f * cameraDimensions.y);

            // Influences sum
            Gizmos.color = EditorPrefsX.GetColor(PrefsData.InfluencesColorKey, PrefsData.InfluencesColorValue);
            if (_influencesSum != Vector3.zero)
            {
                Utils.DrawArrowForGizmo(targetsMidPoint, _influencesSum, .04f * cameraDimensions.y);
            }

            // Overall offset line
            Gizmos.color = EditorPrefsX.GetColor(PrefsData.OverallOffsetColorKey, PrefsData.OverallOffsetColorValue);
            if (OverallOffset != Vector2.zero)
            {
                Utils.DrawArrowForGizmo(targetsMidPoint, VectorHV(OverallOffset.x, OverallOffset.y), .04f * cameraDimensions.y);
            }

            // Limit cam distance
            if (LimitHorizontalCameraDistance)
            {
                Gizmos.color = EditorPrefsX.GetColor(PrefsData.CamDistanceColorKey, PrefsData.CamDistanceColorValue);
                Gizmos.DrawRay(VectorHVD(Vector3H(transform.position) + (cameraDimensions.x / 2) * MaxHorizontalTargetDistance, Vector3V(transform.position) - cameraDimensions.y / 2, cameraDepthOffset), transform.up * cameraDimensions.y);
                Gizmos.DrawRay(VectorHVD(Vector3H(transform.position) - (cameraDimensions.x / 2) * MaxHorizontalTargetDistance, Vector3V(transform.position) - cameraDimensions.y / 2, cameraDepthOffset), transform.up * cameraDimensions.y);
            }

            if (LimitVerticalCameraDistance)
            {
                Gizmos.color = EditorPrefsX.GetColor(PrefsData.CamDistanceColorKey, PrefsData.CamDistanceColorValue);
                Gizmos.DrawRay(VectorHVD(Vector3H(transform.position) - cameraDimensions.x / 2, Vector3V(transform.position) - (cameraDimensions.y / 2) * MaxVerticalTargetDistance, cameraDepthOffset), transform.right * cameraDimensions.x);
                Gizmos.DrawRay(VectorHVD(Vector3H(transform.position) - cameraDimensions.x / 2, Vector3V(transform.position) + (cameraDimensions.y / 2) * MaxVerticalTargetDistance, cameraDepthOffset), transform.right * cameraDimensions.x);
            }

            // Camera target position
            Gizmos.color = EditorPrefsX.GetColor(PrefsData.CamTargetPositionColorKey, PrefsData.CamTargetPositionColorValue);
            var cameraTargetPosition = targetsMidPoint + _influencesSum + VectorHV(OverallOffset.x, OverallOffset.y);
            var cameraTargetPos      = VectorHVD(Vector3H(cameraTargetPosition), Vector3V(cameraTargetPosition), cameraDepthOffset);

            Gizmos.DrawWireSphere(cameraTargetPos, .015f * cameraDimensions.y);

            // Camera target position smoothed
            if (Application.isPlaying)
            {
                Gizmos.color = EditorPrefsX.GetColor(PrefsData.CamTargetPositionSmoothedColorKey, PrefsData.CamTargetPositionSmoothedColorValue);
                var cameraTargetPosSmoothed = VectorHVD(_cameraTargetHorizontalPositionSmoothed, _cameraTargetVerticalPositionSmoothed, cameraDepthOffset);
                Gizmos.DrawWireSphere(cameraTargetPosSmoothed, .02f * cameraDimensions.y);
                Gizmos.DrawLine(cameraTargetPos, cameraTargetPosSmoothed);
            }

            // Current camera position
            Gizmos.color = EditorPrefsX.GetColor(PrefsData.CurrentCameraPositionColorKey, PrefsData.CurrentCameraPositionColorValue);
            var currentCameraPos = VectorHVD(Vector3H(transform.localPosition), Vector3V(transform.localPosition), cameraDepthOffset);

            Gizmos.DrawWireSphere(currentCameraPos, .025f * cameraDimensions.y);

            // Draw camera window
            Gizmos.color = EditorPrefsX.GetColor(PrefsData.CameraWindowColorKey, PrefsData.CameraWindowColorValue);
            var cameraRect = GetRectAroundTransf(CameraWindowRect, cameraDimensions, transform);

            Gizmos.DrawWireCube(VectorHVD(cameraRect.x + cameraRect.width / 2, cameraRect.y + cameraRect.height / 2, cameraDepthOffset), VectorHV(cameraRect.width, cameraRect.height));
        }
Esempio n. 24
0
        void OnDrawGizmos()
        {
            // HACK to prevent Unity bug on startup: http://forum.unity3d.com/threads/screen-position-out-of-view-frustum.9918/
            _drawGizmosCounter++;
            if (_drawGizmosCounter < 5 && UnityEditor.EditorApplication.timeSinceStartup < 60f)
            {
                return;
            }

            if (Vector3H == null)
            {
                ResetAxisFunctions();
            }

            var gameCamera = GetComponent <Camera>();

            // Don't draw gizmos on other cameras
            if (Camera.current != gameCamera &&
                ((UnityEditor.SceneView.lastActiveSceneView != null && Camera.current != UnityEditor.SceneView.lastActiveSceneView.camera) ||
                 (UnityEditor.SceneView.lastActiveSceneView == null)))
            {
                return;
            }

            var   cameraDimensions  = Utils.GetScreenSizeInWorldCoords(gameCamera, Mathf.Abs(Vector3D(transform.position)));
            float cameraDepthOffset = Vector3D(transform.position) + Mathf.Abs(Vector3D(transform.position)) * Vector3D(transform.forward);

            // Targets mid point
            Gizmos.color = EditorPrefsX.GetColor(PrefsData.TargetsMidPointColorKey, PrefsData.TargetsMidPointColorValue);
            var targetsMidPoint = GetTargetsWeightedMidPoint(ref CameraTargets);

            targetsMidPoint = VectorHVD(Vector3H(targetsMidPoint), Vector3V(targetsMidPoint), cameraDepthOffset);
            Gizmos.DrawWireSphere(targetsMidPoint, .01f * cameraDimensions.y);

            // Influences sum
            Gizmos.color = EditorPrefsX.GetColor(PrefsData.InfluencesColorKey, PrefsData.InfluencesColorValue);
            if (_influencesSum != Vector3.zero)
            {
                Utils.DrawArrowForGizmo(targetsMidPoint, _influencesSum, .04f * cameraDimensions.y);
            }

            // Overall offset line
            Gizmos.color = EditorPrefsX.GetColor(PrefsData.OverallOffsetColorKey, PrefsData.OverallOffsetColorValue);
            if (OffsetX != 0 || OffsetY != 0)
            {
                if (IsRelativeOffset)
                {
                    Utils.DrawArrowForGizmo(targetsMidPoint, VectorHV((OffsetX * cameraDimensions.x * .5f), (OffsetY * cameraDimensions.y * .5f)), .04f * cameraDimensions.y);
                }
                else
                {
                    Utils.DrawArrowForGizmo(targetsMidPoint, VectorHV(OffsetX, OffsetY), .04f * cameraDimensions.y);
                }
            }

            // Camera target position
            Gizmos.color = EditorPrefsX.GetColor(PrefsData.CamTargetPositionColorKey, PrefsData.CamTargetPositionColorValue);
            var cameraTargetPosition = targetsMidPoint + _influencesSum + VectorHV((OffsetX * cameraDimensions.x * .5f), (OffsetY * cameraDimensions.y * .5f));

            if (!IsRelativeOffset)
            {
                cameraTargetPosition = targetsMidPoint + _influencesSum + VectorHV(OffsetX, OffsetY);
            }

            var cameraTargetPos = VectorHVD(Vector3H(cameraTargetPosition), Vector3V(cameraTargetPosition), cameraDepthOffset);

            Gizmos.DrawWireSphere(cameraTargetPos, .015f * cameraDimensions.y);

            // Camera target position smoothed
            if (Application.isPlaying)
            {
                Gizmos.color = EditorPrefsX.GetColor(PrefsData.CamTargetPositionSmoothedColorKey, PrefsData.CamTargetPositionSmoothedColorValue);
                var cameraTargetPosSmoothed = VectorHVD(_cameraTargetHorizontalPositionSmoothed + Vector3H(ParentPosition), _cameraTargetVerticalPositionSmoothed + Vector3V(ParentPosition), cameraDepthOffset);
                Gizmos.DrawWireSphere(cameraTargetPosSmoothed, .02f * cameraDimensions.y);
                Gizmos.DrawLine(cameraTargetPos, cameraTargetPosSmoothed);
            }

            // Current camera position
            Gizmos.color = EditorPrefsX.GetColor(PrefsData.CurrentCameraPositionColorKey, PrefsData.CurrentCameraPositionColorValue);
            var currentCameraPos = VectorHVD(Vector3H(transform.position), Vector3V(transform.position), cameraDepthOffset);

            Gizmos.DrawWireSphere(currentCameraPos, .025f * cameraDimensions.y);
        }
        void OnSceneGUI()
        {
            var proCamera2DRooms = (ProCamera2DRooms)target;

            // Text style for room numbers
            var guiStyle = new GUIStyle();

            guiStyle.fontStyle        = FontStyle.Bold;
            guiStyle.fontSize         = 30;
            guiStyle.normal.textColor = EditorPrefsX.GetColor(PrefsData.RoomsColorKey, PrefsData.RoomsColorValue);
            guiStyle.alignment        = TextAnchor.MiddleCenter;
            guiStyle.fixedWidth       = 1f;
            guiStyle.fixedHeight      = 1f;

            Handles.color = EditorPrefsX.GetColor(PrefsData.RoomsColorKey, PrefsData.RoomsColorValue);
            for (int i = 0; i < proCamera2DRooms.Rooms.Count; i++)
            {
                Handles.color = new Color(Handles.color.r, Handles.color.g, Handles.color.b, 0f);

                // Button to toggle room editing
                var buttonSize = Mathf.Min(proCamera2DRooms.Rooms[i].Dimensions.width / 2f, proCamera2DRooms.Rooms[i].Dimensions.height / 2f);
                buttonSize = Mathf.Min(1, buttonSize);
                if (Handles.Button(proCamera2DRooms.Rooms[i].Dimensions.position, Quaternion.LookRotation(VectorHVD(0, 0, 1)), buttonSize, buttonSize, Handles.RectangleCap))
                {
                    if (i == _currentlyEditingRoom)
                    {
                        _currentlyEditingRoom = -1;
                    }
                    else
                    {
                        _currentlyEditingRoom = i;
                    }
                }

                // Room number
                Handles.Label(proCamera2DRooms.Rooms[i].Dimensions.position, i.ToString(), guiStyle);
            }

            // Room rect editor
            if (_currentlyEditingRoom != -1)
            {
                var currentDimensions = proCamera2DRooms.Rooms[_currentlyEditingRoom].Dimensions;

                // Snap value
                var snap = EditorPrefs.GetFloat("RoomsSnapping", PrefsData.RoomsSnapping);

                // Draw rect editor
                var newDimensions = ResizeRect(
                    currentDimensions,
                    Handles.CubeCap,
                    Color.green,
                    Color.yellow,
                    HandleUtility.GetHandleSize(Vector3.zero) * .1f,
                    snap);

                // Undo
                if (newDimensions.x != currentDimensions.x ||
                    newDimensions.y != currentDimensions.y ||
                    newDimensions.width != currentDimensions.width ||
                    newDimensions.height != currentDimensions.height)
                {
                    Undo.RecordObject(proCamera2DRooms, "ResizeRect");
                }

                // Save new dimensions
                proCamera2DRooms.Rooms[_currentlyEditingRoom].Dimensions = newDimensions;

                // Redraw views
                if (Event.current.rawType == EventType.Used)
                {
                    UnityEditorInternal.InternalEditorUtility.RepaintAllViews();
                }
            }
        }
Esempio n. 26
0
        protected override void DrawGizmosSelected()
        {
            base.DrawGizmosSelected();

            var fillColor = EditorPrefsX.GetColor(PrefsData.FitterFillColorKey, PrefsData.FitterFillColorValue);
            var lineColor = EditorPrefsX.GetColor(PrefsData.FitterLineColorKey, PrefsData.FitterFillColorValue);

            Gizmos.color = lineColor;

            var camSize =
                Utils.GetScreenSizeInWorldCoords(ProCamera2D.GameCamera, Mathf.Abs(Vector3D(transform.localPosition)));
            var camPos = VectorHVD(Vector3H(ProCamera2D.transform.position), Vector3V(ProCamera2D.transform.position),
                                   0);

            var rectCorners = DrawGizmoRectangle(
                Vector3H(ProCamera2D.transform.position),
                Vector3V(ProCamera2D.transform.position),
                ContentFitterMode != ContentFitterMode.FixedHeight ? TargetWidth : camSize.x,
                ContentFitterMode != ContentFitterMode.FixedWidth ? TargetHeight : camSize.y,
                fillColor,
                lineColor);

            if (_contentFitterMode == ContentFitterMode.AspectRatio)
            {
                if (TargetHeight * .5f > TargetWidth * .5f / ProCamera2D.GameCamera.aspect)
                {
                    DrawGizmoRectangle(
                        Vector3H(ProCamera2D.transform.position) - HorizontalAlignment * (TargetHeight * ProCamera2D.GameCamera.aspect - TargetWidth) / 2f,
                        Vector3V(ProCamera2D.transform.position),
                        TargetHeight * ProCamera2D.GameCamera.aspect,
                        TargetHeight,
                        fillColor,
                        lineColor);
                }
                else
                {
                    DrawGizmoRectangle(
                        Vector3H(ProCamera2D.transform.position),
                        Vector3V(ProCamera2D.transform.position) - VerticalAlignment * (TargetWidth / ProCamera2D.GameCamera.aspect - TargetHeight) / 2f,
                        TargetWidth,
                        TargetWidth / ProCamera2D.GameCamera.aspect,
                        fillColor,
                        lineColor);
                }

                Utils.DrawArrowForGizmo(camPos, camPos - rectCorners[0], camSize.y * .03f);
                Utils.DrawArrowForGizmo(camPos, camPos - rectCorners[2], camSize.y * .03f);
            }
            else if (_contentFitterMode == ContentFitterMode.FixedWidth)
            {
                DrawGizmoRectangle(
                    Vector3H(ProCamera2D.transform.position),
                    Vector3V(ProCamera2D.transform.position),
                    TargetWidth,
                    TargetWidth / ProCamera2D.GameCamera.aspect,
                    fillColor,
                    lineColor);

                Utils.DrawArrowForGizmo(camPos, ProCamera2D.transform.right * TargetWidth * .5f, camSize.y * .03f);
                Utils.DrawArrowForGizmo(camPos, -ProCamera2D.transform.right * TargetWidth * .5f, camSize.y * .03f);
            }
            else
            {
                DrawGizmoRectangle(
                    Vector3H(ProCamera2D.transform.position),
                    Vector3V(ProCamera2D.transform.position),
                    TargetHeight * ProCamera2D.GameCamera.aspect,
                    TargetHeight,
                    fillColor,
                    lineColor);

                Utils.DrawArrowForGizmo(camPos, ProCamera2D.transform.up * TargetHeight * .5f, camSize.y * .03f);
                Utils.DrawArrowForGizmo(camPos, -ProCamera2D.transform.up * TargetHeight * .5f, camSize.y * .03f);
            }
        }
Esempio n. 27
0
        static void PreferencesGUI()
        {
            // Load the preferences
            if (!_prefsLoaded)
            {
                _procamera2DGizmosColors = new Color[_procamera2DGizmosKeys.Length];
                for (int i = 0; i < _procamera2DGizmosColors.Length; i++)
                {
                    _procamera2DGizmosColors[i] = EditorPrefsX.GetColor(_procamera2DGizmosKeys[i], _procamera2DGizmosValues[i]);
                }

                _prefsLoaded = true;
            }

            // Preferences GUI
            _scrollPos = EditorGUILayout.BeginScrollView(_scrollPos);

            GUILayout.Label("ProCamera2D", EditorStyles.boldLabel);
            for (int i = 0; i < _procamera2DGizmosColors.Length; i++)
            {
                _procamera2DGizmosColors[i] = EditorGUILayout.ColorField(_procamera2DGizmosKeys[i], _procamera2DGizmosColors[i]);

                if (i == 9)
                {
                    EditorGUILayout.Space();
                    GUILayout.Label("Extensions", EditorStyles.boldLabel);
                }

                if (i == 16)
                {
                    EditorGUILayout.Space();
                    GUILayout.Label("Triggers", EditorStyles.boldLabel);
                }
            }

            // Rails snapping
            EditorGUILayout.Space();
            EditorGUILayout.Space();
            GUILayout.Label("Rails Snapping", EditorStyles.boldLabel);
            EditorPrefs.SetFloat("RailsSnapping", EditorGUILayout.Slider(EditorPrefs.GetFloat("RailsSnapping"), .1f, 10f));

            // Rooms snapping
            EditorGUILayout.Space();
            EditorGUILayout.Space();
            GUILayout.Label("Rooms Snapping", EditorStyles.boldLabel);
            EditorPrefs.SetFloat("RoomsSnapping", EditorGUILayout.Slider(EditorPrefs.GetFloat("RoomsSnapping"), .01f, 10f));

            // Reset defaults
            EditorGUILayout.Space();
            EditorGUILayout.Space();
            if (GUILayout.Button("Use defaults", GUILayout.Width(120)))
            {
                for (int i = 0; i < _procamera2DGizmosColors.Length; i++)
                {
                    EditorPrefsX.SetColor(_procamera2DGizmosKeys[i], _procamera2DGizmosValues[i]);
                }
            }

            EditorGUILayout.EndScrollView();

            // Save the preferences
            if (GUI.changed)
            {
                for (int i = 0; i < _procamera2DGizmosColors.Length; i++)
                {
                    EditorPrefsX.SetColor(_procamera2DGizmosKeys[i], _procamera2DGizmosColors[i]);
                }
            }
        }
Esempio n. 28
0
        void OnSceneGUI()
        {
            var proCamera2DRails = (ProCamera2DRails)target;

            // Return if less than 2 nodes
            var nodesCount = proCamera2DRails.RailNodes.Count;

            if (nodesCount < 2)
            {
                return;
            }

            // Detect delete mode
            bool  deleteMode = false;
            Event e          = Event.current;

            if (e.alt)
            {
                deleteMode = true;
            }

            // Handles color
            Handles.color = EditorPrefsX.GetColor(PrefsData.RailsColorKey, PrefsData.RailsColorValue);

            // Draw line between nodes
            Handles.DrawPolyLine(proCamera2DRails.RailNodes.ToArray());

            // Handle size
            float handleSize = HandleUtility.GetHandleSize(Vector3.zero) * .1f;

            // Draw left and right handles
            var rightHandlePos = (proCamera2DRails.RailNodes[nodesCount - 1] - proCamera2DRails.RailNodes[nodesCount - 2]).normalized * .5f + proCamera2DRails.RailNodes[nodesCount - 1];

            if (Handles.Button(
                    rightHandlePos,
                    Quaternion.identity,
                    handleSize * .5f,
                    handleSize,
                #if UNITY_5_5_OR_NEWER
                    Handles.RectangleHandleCap))
                #else
                    Handles.RectangleCap))
                #endif
            {
                Undo.RecordObject(proCamera2DRails, "Add");
                proCamera2DRails.RailNodes.Insert(nodesCount, rightHandlePos);
            }

            var leftHandlesPos = (proCamera2DRails.RailNodes[0] - proCamera2DRails.RailNodes[1]).normalized * .5f + proCamera2DRails.RailNodes[0];
            if (Handles.Button(
                    leftHandlesPos,
                    Quaternion.identity,
                    handleSize * .5f,
                    handleSize,
                #if UNITY_5_5_OR_NEWER
                    Handles.RectangleHandleCap))
                #else
                    Handles.RectangleCap))
                #endif
            {
                Undo.RecordObject(proCamera2DRails, "Add");
                proCamera2DRails.RailNodes.Insert(0, leftHandlesPos);
            }

            // Snap value
            var pointSnap = Vector3.one * EditorPrefs.GetFloat("RailsSnapping", PrefsData.RailsSnapping);

            // Draw a handle for each node
            for (int i = 0; i < nodesCount; i++)
            {
                var oldPos = proCamera2DRails.RailNodes[i];
                var newPos = Handles.FreeMoveHandle(
                    oldPos,
                    Quaternion.identity,
                    handleSize,
                    pointSnap,
                                #if UNITY_5_5_OR_NEWER
                    Handles.DotHandleCap);
                                #else
                    Handles.DotCap);
                                #endif

                // Move
                if (newPos != oldPos)
                {
                    newPos.x = Handles.SnapValue(newPos.x, pointSnap.x);
                    newPos.y = Handles.SnapValue(newPos.y, pointSnap.y);
                    newPos.z = Handles.SnapValue(newPos.z, pointSnap.z);

                    Undo.RecordObject(proCamera2DRails, "Move");
                    proCamera2DRails.RailNodes[i] = VectorHV(Vector3H(newPos), Vector3V(newPos));
                }

                // Draw the midpoint button
                if (i > 0)
                {
                    var midPoint = Vector3.Lerp(proCamera2DRails.RailNodes[i - 1], proCamera2DRails.RailNodes[i], 0.5f);

                    if (Handles.Button(
                            midPoint,
                            Quaternion.identity,
                            handleSize * .5f,
                            handleSize,
                        #if UNITY_5_5_OR_NEWER
                            Handles.RectangleHandleCap))
                        #else
                            Handles.RectangleCap))
                        #endif
                    {
                        Undo.RecordObject(proCamera2DRails, "Add");
                        proCamera2DRails.RailNodes.Insert(i, midPoint);
                    }
                }

                // Draw the delete button
                if (deleteMode && nodesCount > 2)
                {
                    Handles.color = Color.red;
                    var deleteButtonPos = proCamera2DRails.RailNodes[i];
                    if (Handles.Button(
                            deleteButtonPos,
                            Quaternion.identity,
                            handleSize,
                            handleSize,
                        #if UNITY_5_5_OR_NEWER
                            Handles.DotHandleCap))
                        #else
                            Handles.DotCap))
                        #endif
                    {
                        Undo.RecordObject(proCamera2DRails, "Remove");
                        proCamera2DRails.RailNodes.RemoveAt(i);
                        return;
                    }
                    Handles.color = EditorPrefsX.GetColor(PrefsData.RailsColorKey, PrefsData.RailsColorValue);
                }
            }
        }
        void OnSceneGUI()
        {
            var proCamera2DRooms = (ProCamera2DRooms)target;

            if (proCamera2DRooms.ProCamera2D == null)
            {
                return;
            }

            // Text style for room numbers
            var guiStyle = new GUIStyle();

            guiStyle.fontStyle        = FontStyle.Bold;
            guiStyle.fontSize         = 30;
            guiStyle.normal.textColor = EditorPrefsX.GetColor(PrefsData.RoomsColorKey, PrefsData.RoomsColorValue);
            guiStyle.alignment        = TextAnchor.MiddleCenter;
            guiStyle.fixedWidth       = 1f;
            guiStyle.fixedHeight      = 1f;

            Handles.color = EditorPrefsX.GetColor(PrefsData.RoomsColorKey, PrefsData.RoomsColorValue);
            for (int i = 0; i < proCamera2DRooms.Rooms.Count; i++)
            {
                Handles.color = new Color(Handles.color.r, Handles.color.g, Handles.color.b, 0f);

                // Button to toggle room editing
                var buttonSize = Mathf.Min(proCamera2DRooms.Rooms[i].Dimensions.width / 2f, proCamera2DRooms.Rooms[i].Dimensions.height / 2f);
                buttonSize = Mathf.Min(1, buttonSize);

                var buttonPosition = proCamera2DRooms.Rooms[i].Dimensions.position;
                if (proCamera2DRooms.UseRelativePosition)
                {
                    buttonPosition.x += Vector3H(proCamera2DRooms.transform.position);
                    buttonPosition.y += Vector3V(proCamera2DRooms.transform.position);
                }

                if (Handles.Button(
                        buttonPosition,
                        Quaternion.LookRotation(VectorHVD(0, 0, 1)),
                        buttonSize,
                        buttonSize,
#if UNITY_5_5_OR_NEWER
                        Handles.RectangleHandleCap))
#else
                        Handles.RectangleCap))
#endif
                {
                    if (i == _currentlyEditingRoom)
                    {
                        _currentlyEditingRoom = -1;
                    }
                    else
                    {
                        _currentlyEditingRoom = i;
                    }
                }

                // Room number
                Handles.Label(VectorHV(buttonPosition.x, buttonPosition.y), i.ToString(), guiStyle);
            }

            // Room rect editor
            if (_currentlyEditingRoom != -1)
            {
                var currentDimensions = proCamera2DRooms.Rooms[_currentlyEditingRoom].Dimensions;

                // Snap value
                var snap = EditorPrefs.GetFloat("RoomsSnapping", PrefsData.RoomsSnapping);

                // Move
                var oldPos = VectorHV(currentDimensions.position.x, currentDimensions.position.y);
                if (proCamera2DRooms.UseRelativePosition)
                {
                    oldPos.x += Vector3H(proCamera2DRooms.transform.position);
                    oldPos.y += Vector3V(proCamera2DRooms.transform.position);
                }

                var newPos = Handles.PositionHandle(oldPos, Quaternion.identity);
                if (newPos != oldPos)
                {
                    Undo.RecordObject(proCamera2DRooms, "MoveRoom");
                    currentDimensions.position = new Vector2(Vector3H(newPos), Vector3V(newPos));

                    if (proCamera2DRooms.UseRelativePosition)
                    {
                        currentDimensions.x -= Vector3H(proCamera2DRooms.transform.position);
                        currentDimensions.y -= Vector3V(proCamera2DRooms.transform.position);
                    }
                }

                // Draw rect editor
                var currentDimensionsRelative = currentDimensions;
                if (proCamera2DRooms.UseRelativePosition)
                {
                    currentDimensionsRelative.x += Vector3H(proCamera2DRooms.transform.position);
                    currentDimensionsRelative.y += Vector3V(proCamera2DRooms.transform.position);
                }

                var newDimensions = ResizeRect(
                    currentDimensionsRelative,
#if UNITY_5_5_OR_NEWER
                    Handles.CubeHandleCap,
#else
                    Handles.CubeCap,
#endif
                    Color.green,
                    Color.yellow,
                    HandleUtility.GetHandleSize(Vector3.zero) * .1f,
                    snap);


                // Undo
                if (newDimensions.x != currentDimensionsRelative.x ||
                    newDimensions.y != currentDimensionsRelative.y ||
                    newDimensions.width != currentDimensionsRelative.width ||
                    newDimensions.height != currentDimensionsRelative.height)
                {
                    Undo.RecordObject(proCamera2DRooms, "ResizeRect");
                }

                // Save new dimensions
                var newDimensionsRelative = newDimensions;
                if (proCamera2DRooms.UseRelativePosition)
                {
                    newDimensionsRelative.x -= Vector3H(proCamera2DRooms.transform.position);
                    newDimensionsRelative.y -= Vector3V(proCamera2DRooms.transform.position);
                }

                proCamera2DRooms.Rooms[_currentlyEditingRoom].Dimensions = newDimensionsRelative;

                // Redraw views
                if (Event.current.rawType == EventType.Used)
                {
                    UnityEditorInternal.InternalEditorUtility.RepaintAllViews();
                }
            }
        }
        override protected void DrawGizmos()
        {
            base.DrawGizmos();

            var   gameCamera        = ProCamera2D.GetComponent <Camera>();
            var   cameraDimensions  = gameCamera.orthographic ? Utils.GetScreenSizeInWorldCoords(gameCamera) : Utils.GetScreenSizeInWorldCoords(gameCamera, Mathf.Abs(Vector3D(transform.localPosition)));
            float cameraDepthOffset = Vector3D(ProCamera2D.transform.localPosition) + Mathf.Abs(Vector3D(transform.localPosition)) * Vector3D(ProCamera2D.transform.forward);
            var   cameraCenter      = VectorHVD(Vector3H(transform.position), Vector3V(transform.position), cameraDepthOffset);

            var bordersColor = DisableWhenOneTarget && ProCamera2D.CameraTargets.Count <= 1 ? EditorPrefsX.GetColor(PrefsData.ZoomToFitColorKey, Color.white) * .75f : EditorPrefsX.GetColor(PrefsData.ZoomToFitColorKey, Color.white);

            // Zoom out border
            Gizmos.color = Math.Abs(_targetCamSizeSmoothed - _maxCameraSize) < .01f ? bordersColor * .5f : bordersColor;
            Gizmos.DrawWireCube(cameraCenter, VectorHV(cameraDimensions.x, cameraDimensions.y) * ZoomOutBorder);
            Utils.DrawArrowForGizmo(cameraCenter + VectorHV(cameraDimensions.x / 2 * ZoomOutBorder, cameraDimensions.y / 2 * ZoomOutBorder), VectorHV(.05f * cameraDimensions.y, .05f * cameraDimensions.y), .04f * cameraDimensions.y);
            Utils.DrawArrowForGizmo(cameraCenter - VectorHV(cameraDimensions.x / 2 * ZoomOutBorder, cameraDimensions.y / 2 * ZoomOutBorder), VectorHV(-.05f * cameraDimensions.y, -.05f * cameraDimensions.y), .04f * cameraDimensions.y);

            // Zoom in border
            Gizmos.color = Math.Abs(_targetCamSizeSmoothed - _minCameraSize) < .01f ? bordersColor * .75f : bordersColor;
            Gizmos.DrawWireCube(cameraCenter, VectorHV(cameraDimensions.x, cameraDimensions.y) * ZoomInBorder);
            Utils.DrawArrowForGizmo(cameraCenter + VectorHV(cameraDimensions.x / 2 * ZoomInBorder, cameraDimensions.y / 2 * ZoomInBorder), VectorHV(-.05f * cameraDimensions.y, -.05f * cameraDimensions.y), .04f * cameraDimensions.y);
            Utils.DrawArrowForGizmo(cameraCenter - VectorHV(cameraDimensions.x / 2 * ZoomInBorder, cameraDimensions.y / 2 * ZoomInBorder), VectorHV(.05f * cameraDimensions.y, .05f * cameraDimensions.y), .04f * cameraDimensions.y);
        }