Skip to content

Commit

Permalink
fix: baking camera settings for camera space
Browse files Browse the repository at this point in the history
  • Loading branch information
mob-sakai committed Aug 28, 2020
1 parent a86df3a commit 436c5e4
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions Packages/UIParticle/Scripts/BakingCamera.cs
Original file line number Diff line number Diff line change
@@ -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;
Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit 436c5e4

Please sign in to comment.