/// <summary> /// 퍼시펙티브 카메라 화면 크기에 맞는 오브젝트의 스케일 크기를 리턴. /// 카메라 to 오브젝트의 거리에 맞게 스케일할 크기를 알려준다. /// </summary> /// <remarks>참조: http://answers.unity3d.com/questions/391324/stretching-a-gameobject-to-fit-viewport.html</remarks> /// <returns>스케일값</returns> static public Vector3 getScaleForPerspectiveCamera(GameObject targetObject_) { float _dist = Vector3.Distance(targetObject_.transform.position, Camera.main.transform.position); float _objDepth = targetObject_.transform.localScale.z; _dist -= (_objDepth * 0.5f); Vector3 v3ViewPort = new Vector3(0, 0, _dist); Vector3 v3BottomLeft = Camera.main.ViewportToWorldPoint(v3ViewPort); v3ViewPort.Set(1, 1, _dist); Vector3 v3TopRight = Camera.main.ViewportToWorldPoint(v3ViewPort); return new Vector3(v3BottomLeft.x - v3TopRight.x, v3BottomLeft.y - v3TopRight.y, _objDepth); }