Example #1
0
        private void Zoom()
        {
            if (_camera == null)
            {
                _camera = GetComponent <Camera>();
            }
            var objectToView = transform.parent.transform;

            if (objectToView == null)
            {
                return;
            }
            var objs   = objectToView.GetComponentsInChildren <Renderer>();
            var bounds = objs[0].bounds;

            for (int i = 1; i < objs.Length; i++)
            {
                bounds.Encapsulate(objs[i].bounds);
            }
            var dir = SpriteFacingControl.GetCameraSide(SpriteFacing.Eightway, objectToView, objectToView, 0f, out var inMargin);

            SpriteFacingControl.SetCameraPos(Camera, dir, _viewOffset, 0f);
            if (main._debug)
            {
                DebugExtension.DebugBounds(bounds, Color.red, 5f);
            }
            Zoom(bounds);
            PositionBottom(objectToView.transform.position);
        }
Example #2
0
 public static void TakePicture(Transform parent, Bounds bounds, DirectionsEight dir, RenderTexture texture)
 {
     Camera.enabled          = true;
     Camera.transform.parent = parent;
     Camera.targetTexture    = texture;
     SpriteFacingControl.SetCameraPos(Camera, dir, main._viewOffset, 0f);
     if (main._debug)
     {
         DebugExtension.DebugArrow(Camera.transform.position, Camera.transform.forward, Color.blue, 5f);
     }
     main.Zoom(bounds);
     main.PositionBottom(parent.position);
     _canvasHackField.SetValue(null, null);
     Camera.Render();
     _canvasHackField.SetValue(null, _canvasHackObject);
     Camera.Render();
     Camera.enabled = false;
     //Camera.targetTexture = null;
     Camera.transform.parent = null;
 }