示例#1
0
        void AddParallaxLayer()
        {
            var go  = new GameObject("ParallaxCamera");
            var cam = go.AddComponent <Camera>();

            EditorUtility.CopySerialized(_proCamera2D.GameCamera, cam);
            go.transform.parent        = _proCamera2D.transform;
            go.transform.localPosition = Vector3.zero;

            cam.cullingMask = 0;
            cam.clearFlags  = CameraClearFlags.Depth;

            var parallaxLayer = new ProCamera2DParallaxLayer();

            parallaxLayer.ParallaxCamera = cam;
            parallaxLayer.Speed          = 1;

            #if PC2D_TK2D_SUPPORT
            if (_proCamera2D.GetComponent <tk2dCamera>() != null)
            {
                var tk2dCam = go.AddComponent <tk2dCamera>();
                tk2dCam.InheritConfig            = _proCamera2D.GetComponent <tk2dCamera>();
                parallaxLayer.ParallaxCameraTk2d = tk2dCam;
            }
            #endif

            _proCamera2DParallax.ParallaxLayers.Add(parallaxLayer);
        }
示例#2
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);
                }
            }
        }
示例#3
0
        override protected void DrawGizmos()
        {
            _exclusiveInfluencePercentage = ExclusiveInfluencePercentage;

            base.DrawGizmos();

            float cameraDepthOffset = Vector3D(ProCamera2D.transform.localPosition) + Mathf.Abs(Vector3D(ProCamera2D.transform.localPosition)) * Vector3D(ProCamera2D.transform.forward);

            if (FocusPoint != null)
            {
                if (FocusPoint.position != Vector3.zero)
                {
                    Gizmos.DrawLine(VectorHVD(Vector3H(transform.position), Vector3V(transform.position), cameraDepthOffset), VectorHVD(Vector3H(FocusPoint.position), Vector3V(FocusPoint.position), cameraDepthOffset));
                }

                Gizmos.DrawIcon(VectorHVD(Vector3H(FocusPoint.position), Vector3V(FocusPoint.position), cameraDepthOffset), "ProCamera2D/gizmo_icon_influence.png", false);
            }
            else
            {
                Gizmos.DrawIcon(VectorHVD(Vector3H(transform.position), Vector3V(transform.position), cameraDepthOffset), "ProCamera2D/gizmo_icon_influence.png", false);
            }

            //Draw camera limits in trigger
            var cameraDimensions = Utils.GetScreenSizeInWorldCoords(ProCamera2D.GetComponent <Camera>(), Mathf.Abs(Vector3D(ProCamera2D.transform.localPosition)));

            Gizmos.color = Color.white;
            Gizmos.DrawRay(VectorHVD(Vector3H(transform.position) - cameraDimensions.x / 2, Vector3V(transform.position) + cameraDimensions.y / 2, cameraDepthOffset),
                           ProCamera2D.transform.right * cameraDimensions.x);
            Gizmos.DrawRay(VectorHVD(Vector3H(transform.position) - cameraDimensions.x / 2, Vector3V(transform.position) + cameraDimensions.y / 2, cameraDepthOffset),
                           ProCamera2D.transform.up * -cameraDimensions.y);
            Gizmos.DrawRay(VectorHVD(Vector3H(transform.position) - cameraDimensions.x / 2, Vector3V(transform.position) - cameraDimensions.y / 2, cameraDepthOffset),
                           ProCamera2D.transform.right * cameraDimensions.x);
            Gizmos.DrawRay(VectorHVD(Vector3H(transform.position) + cameraDimensions.x / 2, Vector3V(transform.position) - cameraDimensions.y / 2, cameraDepthOffset),
                           ProCamera2D.transform.up * cameraDimensions.y);
        }
        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));
        }
示例#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);
            }
        }
        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));
        }
示例#7
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);
            }
        }
        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));
                }
            }
        }
示例#9
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;
            }

            _exclusiveInfluencePercentage = ExclusiveInfluencePercentage;

            base.OnDrawGizmos();

            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 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.DrawIcon(
                VectorHVD(
                    Vector3H(transform.position),
                    Vector3V(transform.position),
                    cameraDepthOffset),
                startCamSize > finalTargetSize ? "ProCamera2D/gizmo_icon_zoom_in.png" : "ProCamera2D/gizmo_icon_zoom_out.png",
                false);

            if (ResetSizeOnExit)
            {
                Gizmos.DrawIcon(
                    VectorHVD(
                        Vector3H(transform.position),
                        Vector3V(transform.position),
                        cameraDepthOffset),
                    "ProCamera2D/gizmo_icon_reset.png",
                    false);
            }
        }
        void GetPixelPerfectPlugin()
        {
            _pixelPerfectPlugin = ProCamera2D.GetComponent <ProCamera2DPixelPerfect>();

#if UNITY_EDITOR
            if (_pixelPerfectPlugin == null)
            {
                Debug.LogWarning("PixelPerfect extension not present. Please add it to the ProCamera2D core.");
            }
#endif
        }
示例#11
0
        override protected void Awake()
        {
            base.Awake();

            _numericBoundaries = ProCamera2D.GetComponent <ProCamera2DNumericBoundaries>();
            _defaultNumericBoundariesSettings = _numericBoundaries.Settings;

            OriginalSize = ProCamera2D.ScreenSizeInWorldCoordinates.y / 2;

            ProCamera2D.AddPositionOverrider(this);
            ProCamera2D.AddSizeOverrider(this);
        }
        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));
        }
        void OnDrawGizmosSelected()
        {
            if (ProCamera2D == null)
            {
                return;
            }

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

            // Draw cinematic path
            GUIStyle style = new GUIStyle();

            style.normal.textColor = Color.green;
            for (int i = 0; i < CinematicTargets.Count; i++)
            {
                var targetPos = VectorHVD(Vector3H(CinematicTargets[i].TargetTransform.position), Vector3V(CinematicTargets[i].TargetTransform.position), cameraDepthOffset);

                if (i > 0)
                {
                    UnityEditor.Handles.DrawLine(targetPos, VectorHVD(Vector3H(CinematicTargets[i - 1].TargetTransform.position), Vector3V(CinematicTargets[i - 1].TargetTransform.position), cameraDepthOffset));
                }

                UnityEditor.Handles.color = Color.blue;
                if (i < CinematicTargets.Count - 1)
                {
                    var nextTargetPos = VectorHVD(Vector3H(CinematicTargets[i + 1].TargetTransform.position), Vector3V(CinematicTargets[i + 1].TargetTransform.position), cameraDepthOffset);
                    var arrowSize     = cameraDimensions.x * .1f;
                    if ((nextTargetPos - targetPos).magnitude > arrowSize)
                    {
#if UNITY_5_5_OR_NEWER
                        UnityEditor.Handles.ArrowHandleCap(
                            i,
                            targetPos,
                            Quaternion.LookRotation(nextTargetPos - targetPos),
                            cameraDimensions.x * .1f,
                            EventType.Repaint);
#else
                        UnityEditor.Handles.ArrowCap(
                            i,
                            targetPos,
                            Quaternion.LookRotation(nextTargetPos - targetPos),
                            cameraDimensions.x * .1f);
#endif
                    }
                }
            }
        }
        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);
        }
示例#15
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;
            }

            base.OnDrawGizmos();

            if (_gizmosDrawingFailed)
            {
                return;
            }

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

            // Draw cinematic path
            GUIStyle style = new GUIStyle();

            style.normal.textColor = Color.green;
            for (int i = 0; i < CinematicTargets.Count; i++)
            {
                var targetPos = VectorHVD(Vector3H(CinematicTargets[i].TargetTransform.position), Vector3V(CinematicTargets[i].TargetTransform.position), cameraDepthOffset);

                if (i > 0)
                {
                    UnityEditor.Handles.DrawLine(targetPos, VectorHVD(Vector3H(CinematicTargets[i - 1].TargetTransform.position), Vector3V(CinematicTargets[i - 1].TargetTransform.position), cameraDepthOffset));
                }

                UnityEditor.Handles.color = Color.blue;
                if (i < CinematicTargets.Count - 1)
                {
                    var nextTargetPos = VectorHVD(Vector3H(CinematicTargets[i + 1].TargetTransform.position), Vector3V(CinematicTargets[i + 1].TargetTransform.position), cameraDepthOffset);
                    var arrowSize     = cameraDimensions.x * .1f;
                    if ((nextTargetPos - targetPos).magnitude > arrowSize)
                    {
                        UnityEditor.Handles.ArrowCap(
                            i,
                            targetPos,
                            Quaternion.LookRotation(nextTargetPos - targetPos),
                            cameraDimensions.x * .1f);
                    }
                }
            }
        }
示例#16
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 DrawGizmos()
        {
            _exclusiveInfluencePercentage = ExclusiveInfluencePercentage;

            base.DrawGizmos();

            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 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.DrawIcon(
                VectorHVD(
                    Vector3H(transform.position),
                    Vector3V(transform.position),
                    cameraDepthOffset),
                startCamSize > finalTargetSize ? "ProCamera2D/gizmo_icon_zoom_in.png" : "ProCamera2D/gizmo_icon_zoom_out.png",
                false);

            if (ResetSizeOnExit)
            {
                Gizmos.DrawIcon(
                    VectorHVD(
                        Vector3H(transform.position),
                        Vector3V(transform.position),
                        cameraDepthOffset),
                    "ProCamera2D/gizmo_icon_reset.png",
                    false);
            }
        }
        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);
                }
            }
        }
示例#19
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));
            }
        }
示例#20
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));
        }
示例#21
0
        protected override void Start()
        {
            base.Start();

            _pixelPerfectPlugin = ProCamera2D.GetComponent <ProCamera2DPixelPerfect>();

            var spriteRenderer = GetComponent <SpriteRenderer>();

            if (spriteRenderer != null)
            {
                _sprite = spriteRenderer.sprite;
            }

            #if PC2D_TK2D_SUPPORT
            if (_sprite == null)
            {
                _spriteTk2d = GetComponent <tk2dSprite>();
            }
            #endif

            SetAsPixelPerfect();
        }
        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));
            }
        }
        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);
        }
示例#24
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);
        }
示例#25
0
 void GetPixelPerfectPlugin()
 {
     _pixelPerfectPlugin = ProCamera2D.GetComponent <ProCamera2DPixelPerfect>();
 }
示例#26
0
        protected override void Start()
        {
            base.Start();

            if (ProCamera2D == null)
            {
                return;
            }

            if (PositionAndSizeOverrider == null)
            {
                var positionAndSizeOverrider = ProCamera2D.GetComponent <ProCamera2DPositionAndSizeOverrider>();
                PositionAndSizeOverrider = positionAndSizeOverrider == null?ProCamera2D.gameObject.AddComponent <ProCamera2DPositionAndSizeOverrider>() : positionAndSizeOverrider;

                PositionAndSizeOverrider.hideFlags = HideFlags.HideInInspector;
            }

            if (NumericBoundaries == null)
            {
                var numericBoundaries = FindObjectOfType <ProCamera2DNumericBoundaries>();
                NumericBoundaries = numericBoundaries == null?ProCamera2D.gameObject.AddComponent <ProCamera2DNumericBoundaries>() : numericBoundaries;
            }

            _boundsAnim = new BoundariesAnimator(ProCamera2D, NumericBoundaries);
            _boundsAnim.OnTransitionStarted += () =>
            {
                if (ProCamera2D.OnBoundariesTransitionStarted != null)
                {
                    ProCamera2D.OnBoundariesTransitionStarted();
                }
            };

            _boundsAnim.OnTransitionFinished += () =>
            {
                if (ProCamera2D.OnBoundariesTransitionFinished != null)
                {
                    ProCamera2D.OnBoundariesTransitionFinished();
                }
            };

            GetTargetBoundaries();

            if (SetAsStartingBoundaries)
            {
                NumericBoundaries.CurrentBoundariesTriggerID = _instanceID;

                NumericBoundaries.UseLeftBoundary = UseLeftBoundary;
                if (UseLeftBoundary)
                {
                    NumericBoundaries.LeftBoundary = NumericBoundaries.TargetLeftBoundary = _targetLeftBoundary;
                }

                NumericBoundaries.UseRightBoundary = UseRightBoundary;
                if (UseRightBoundary)
                {
                    NumericBoundaries.RightBoundary = NumericBoundaries.TargetRightBoundary = _targetRightBoundary;
                }

                NumericBoundaries.UseTopBoundary = UseTopBoundary;
                if (UseTopBoundary)
                {
                    NumericBoundaries.TopBoundary = NumericBoundaries.TargetTopBoundary = _targetTopBoundary;
                }

                NumericBoundaries.UseBottomBoundary = UseBottomBoundary;
                if (UseBottomBoundary)
                {
                    NumericBoundaries.BottomBoundary = NumericBoundaries.TargetBottomBoundary = _targetBottomBoundary;
                }

                if (!UseTopBoundary && !UseBottomBoundary && !UseLeftBoundary && !UseRightBoundary)
                {
                    NumericBoundaries.UseNumericBoundaries = false;
                }
                else
                {
                    NumericBoundaries.UseNumericBoundaries = true;
                }
            }

            _initialCamSize = ProCamera2D.GameCameraSize;
        }