fix: despite not using the size module, particles become smaller based on their z position
close #316pull/336/head
parent
4c285fde14
commit
c43ba67a9b
|
@ -101,7 +101,7 @@ namespace Coffee.UIExtensions
|
||||||
|
|
||||||
private readonly List<UIParticleRenderer> _renderers = new List<UIParticleRenderer>();
|
private readonly List<UIParticleRenderer> _renderers = new List<UIParticleRenderer>();
|
||||||
private int _groupId;
|
private int _groupId;
|
||||||
private Camera _orthoCamera;
|
private Camera _bakeCamera;
|
||||||
private DrivenRectTransformTracker _tracker;
|
private DrivenRectTransformTracker _tracker;
|
||||||
private Vector3 _storedScale;
|
private Vector3 _storedScale;
|
||||||
private bool _isScaleStored;
|
private bool _isScaleStored;
|
||||||
|
@ -581,56 +581,47 @@ namespace Coffee.UIExtensions
|
||||||
private Camera GetBakeCamera()
|
private Camera GetBakeCamera()
|
||||||
{
|
{
|
||||||
if (!canvas) return Camera.main;
|
if (!canvas) return Camera.main;
|
||||||
|
if (_bakeCamera) return _bakeCamera;
|
||||||
|
|
||||||
// When render mode is ScreenSpaceCamera or WorldSpace, use world camera.
|
// Find existing baking camera.
|
||||||
var root = canvas.rootCanvas;
|
var childCount = transform.childCount;
|
||||||
if (root.renderMode != RenderMode.ScreenSpaceOverlay)
|
for (var i = 0; i < childCount; i++)
|
||||||
{
|
{
|
||||||
return root.worldCamera ? root.worldCamera : Camera.main;
|
if (transform.GetChild(i).TryGetComponent<Camera>(out var cam)
|
||||||
}
|
&& cam.name == "[generated] UIParticle BakingCamera")
|
||||||
|
|
||||||
// When render mode is ScreenSpaceOverlay, use ortho-camera.
|
|
||||||
if (!_orthoCamera)
|
|
||||||
{
|
{
|
||||||
// Find existing ortho-camera.
|
_bakeCamera = cam;
|
||||||
foreach (Transform child in transform)
|
|
||||||
{
|
|
||||||
var cam = child.GetComponent<Camera>();
|
|
||||||
if (cam && cam.name == "[generated] UIParticleOverlayCamera")
|
|
||||||
{
|
|
||||||
_orthoCamera = cam;
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Create ortho-camera.
|
// Create baking camera.
|
||||||
if (!_orthoCamera)
|
if (!_bakeCamera)
|
||||||
{
|
{
|
||||||
var go = new GameObject("[generated] UIParticleOverlayCamera")
|
var go = new GameObject("[generated] UIParticle BakingCamera")
|
||||||
{
|
{
|
||||||
hideFlags = HideFlags.HideAndDontSave
|
// hideFlags = HideFlags.HideAndDontSave
|
||||||
|
hideFlags = HideFlags.DontSave
|
||||||
};
|
};
|
||||||
go.SetActive(false);
|
go.SetActive(false);
|
||||||
go.transform.SetParent(transform, false);
|
go.transform.SetParent(transform, false);
|
||||||
_orthoCamera = go.AddComponent<Camera>();
|
_bakeCamera = go.AddComponent<Camera>();
|
||||||
_orthoCamera.enabled = false;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
// Setup baking camera.
|
||||||
var size = ((RectTransform)root.transform).rect.size;
|
_bakeCamera.enabled = false;
|
||||||
_orthoCamera.orthographicSize = Mathf.Max(size.x, size.y) * root.scaleFactor;
|
_bakeCamera.orthographicSize = 1000;
|
||||||
_orthoCamera.transform.SetPositionAndRotation(new Vector3(0, 0, -1000), Quaternion.identity);
|
_bakeCamera.transform.SetPositionAndRotation(new Vector3(0, 0, -1000), Quaternion.identity);
|
||||||
_orthoCamera.orthographic = true;
|
_bakeCamera.orthographic = true;
|
||||||
_orthoCamera.farClipPlane = 2000f;
|
_bakeCamera.farClipPlane = 2000f;
|
||||||
_orthoCamera.clearFlags = CameraClearFlags.Nothing;
|
_bakeCamera.clearFlags = CameraClearFlags.Nothing;
|
||||||
_orthoCamera.cullingMask = 0; // Nothing
|
_bakeCamera.cullingMask = 0; // Nothing
|
||||||
_orthoCamera.allowHDR = false;
|
_bakeCamera.allowHDR = false;
|
||||||
_orthoCamera.allowMSAA = false;
|
_bakeCamera.allowMSAA = false;
|
||||||
_orthoCamera.renderingPath = RenderingPath.Forward;
|
_bakeCamera.renderingPath = RenderingPath.Forward;
|
||||||
_orthoCamera.useOcclusionCulling = false;
|
_bakeCamera.useOcclusionCulling = false;
|
||||||
|
|
||||||
return _orthoCamera;
|
return _bakeCamera;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue