From 436c5e47f75c3e167dcd77c188847e9d7d6ea68d Mon Sep 17 00:00:00 2001 From: mob-sakai Date: Tue, 25 Aug 2020 10:57:16 +0900 Subject: [PATCH] fix: baking camera settings for camera space --- Packages/UIParticle/Scripts/BakingCamera.cs | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/Packages/UIParticle/Scripts/BakingCamera.cs b/Packages/UIParticle/Scripts/BakingCamera.cs index b848d3e..70130df 100644 --- a/Packages/UIParticle/Scripts/BakingCamera.cs +++ b/Packages/UIParticle/Scripts/BakingCamera.cs @@ -1,11 +1,12 @@ -using System; -using UnityEngine; +using UnityEngine; namespace Coffee.UIExtensions { internal class BakingCamera : MonoBehaviour { static BakingCamera s_Instance; + private static readonly Vector3 s_OrthoPosition = new Vector3(0, 0, -1000); + private static readonly Quaternion s_OrthoRotation = Quaternion.identity; #if UNITY_2018_3_OR_NEWER && UNITY_EDITOR static BakingCamera s_InstanceForPrefab; @@ -106,11 +107,18 @@ public static Camera GetCamera(Canvas canvas) { var cameraTr = camera.transform; transform.SetPositionAndRotation(cameraTr.position, cameraTr.rotation); + + Instance._camera.orthographic = camera.orthographic; + Instance._camera.orthographicSize = camera.orthographicSize; + Instance._camera.fieldOfView = camera.fieldOfView; + Instance._camera.nearClipPlane = camera.nearClipPlane; + Instance._camera.farClipPlane = camera.farClipPlane; + Instance._camera.rect = camera.rect; } else { Instance._camera.orthographic = true; - transform.SetPositionAndRotation(Vector3.zero, Quaternion.identity); + transform.SetPositionAndRotation(canvas.transform.position + s_OrthoPosition, s_OrthoRotation); } return Instance._camera;