void Start() { CameraAnchor cameraAnchor = transform.parent.parent.Find("CameraAnchor_TwoPerspectives").GetComponent <CameraAnchor>(); anchorBoneTransform = cameraAnchor.GetAnchorTransform(); headCorrectionRot = Quaternion.Inverse(Quaternion.LookRotation(transform.forward)) * anchorBoneTransform.rotation; }
/// <summary> /// Sets the Anchor for this Camera when it is resized based on a given enum description /// </summary> /// <param name="_anchor"></param> public void SetAnchorBasedOnEnum (CameraAnchor _anchor) { switch (_anchor) { case CameraAnchor.Center: vectorAnchor = new Vector2(0.5f, 0.5f); break; case CameraAnchor.Top: vectorAnchor = new Vector2(0.5f, 1f); break; case CameraAnchor.Bottom: vectorAnchor = new Vector2(0.5f, 0f); break; case CameraAnchor.Left: vectorAnchor = new Vector2(0f, 0.5f); break; case CameraAnchor.Right: vectorAnchor = new Vector2(1f, 0.5f); break; case CameraAnchor.TopLeft: vectorAnchor = new Vector2(0f, 1f); break; case CameraAnchor.TopRight: vectorAnchor = new Vector2(1f, 1f); break; case CameraAnchor.BottomLeft: vectorAnchor = new Vector2(0f, 0f); break; case CameraAnchor.BottomRight: vectorAnchor = new Vector2(1f, 0f); break; } }
public void SetTarget(CameraAnchor _cameraAnchor) { if (_cameraAnchor && target != _cameraAnchor) { target = _cameraAnchor; transitionTimer.Start(); } }
public void InitializeForNewCharacter( Animator animator, CameraAnchor cameraAnchor ) { avatarTransform = animator.transform; this.animator = animator; this.cameraAnchor = cameraAnchor; if ( oldScale != 0 ) initialLocalPosition *= cameraAnchor.avatarScale / (avatarTransform.localScale.x * oldScale); }
public static Vector2 GetCameraPosition(Camera targetCam, CameraAnchor anchor, float paddingX = 0, float paddingY = 0) { Vector2 pos = targetCam.transform.position; Vector2 extent = GetCameraSize() / 2; pos.x += anchor.Contains(CameraAnchor.Right) ? Mathf.Lerp(extent.x, -extent.x, paddingX) : 0; pos.x += anchor.Contains(CameraAnchor.Left) ? Mathf.Lerp(-extent.x, extent.x, paddingX) : 0; pos.y += anchor.Contains(CameraAnchor.Top) ? Mathf.Lerp(extent.y, -extent.y, paddingY) : 0; pos.y += anchor.Contains(CameraAnchor.Bottom) ? Mathf.Lerp(-extent.y, extent.y, paddingY) : 0; return(pos); }
private void Awake() { if (!zedManager) { zedManager = ZEDManager.GetInstance(sl.ZED_CAMERA_ID.CAMERA_ID_01); } if (!camAnchor) { camAnchor = FindObjectOfType <CameraAnchor>(); } SetUpBalls(false); }
public void MoveToNextAnchor() { _currentIndex++; for (int i = 0; i < _anchors.Length; ++i) { if (_anchors[i].index == _currentIndex) { _currentAnchor = _anchors[i]; _currentMovementTime = 0f; _startPosition = transform.position; _isMoving = true; _onTransitionStart.Invoke(); } } }
private void ComputeResolution() { float deviceWidth; float deviceHeight; float leftX, rightX, topY, bottomY; deviceWidth = Screen.width; deviceHeight = Screen.height; if (constraint == Constraint.Landscape) { camera.orthographicSize = 1f / camera.aspect * UnitsSize / 2f; } else { camera.orthographicSize = UnitsSize / 2f; } _height = 2f * camera.orthographicSize; _width = _height * camera.aspect; float cameraX, cameraY; cameraX = camera.transform.position.x; cameraY = camera.transform.position.y; leftX = cameraX - _width / 2; rightX = cameraX + _width / 2; topY = cameraY + _height / 2; bottomY = cameraY - _height / 2; //*** bottom _bl = new Vector3(leftX, bottomY, 0); _bc = new Vector3(cameraX, bottomY, 0); _br = new Vector3(rightX, bottomY, 0); //*** middle _ml = new Vector3(leftX, cameraY, 0); _mc = new Vector3(cameraX, cameraY, 0); _mr = new Vector3(rightX, cameraY, 0); //*** top _tl = new Vector3(leftX, topY, 0); _tc = new Vector3(cameraX, topY, 0); _tr = new Vector3(rightX, topY, 0); Instance = this; }
private void Awake() { defaultScale = transform.localScale; camAnchor = Camera.main.GetComponentInParent <CameraAnchor>(); }
/// <summary> /// Gets the world position of the requested point of the edge/corner of the camera. /// If you want, you can specify an padding calculated in percentage of the screen. /// i.e. TLCorner, .3, .4 will return the point at 30% of width and 40% of height, starting from the Top Left. /// Leave padding to zero if you just want the corresponding point of the CameraAnchor. /// Padding will only work if the anchor touches the corresponding border. i.e. paddingX will not affect Top anchor. /// </summary> public static Vector2 GetCameraPosition(CameraAnchor anchor, float paddingX = 0, float paddingY = 0) { return(GetCameraPosition(Camera.main, anchor, paddingX, paddingY)); }
// Use this for initialization void Start() { Anchor = transform.parent.GetComponent <CameraAnchor>(); Camera = Camera.main; }
/// <summary> /// Changes the anchor object. /// </summary> private void SetNewAnchor(CameraAnchor newanchor) { anchor = newanchor; //TODO: Reposition arrows accordingly. }
/// <summary> /// Changes the anchor object. /// </summary> private void SetNewAnchor(CameraAnchor newanchor) { anchor = newanchor; }