Skip to content

Commit

Permalink
fix: the camera under UIParticle will be assigned as _orthoCamera
Browse files Browse the repository at this point in the history
Prevents unintended camera control
  • Loading branch information
mob-sakai committed Aug 18, 2023
1 parent 9b2e5c1 commit c42f8c8
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion Scripts/UIParticle.cs
Original file line number Diff line number Diff line change
Expand Up @@ -582,7 +582,16 @@ private Camera GetBakeCamera()
// When render mode is ScreenSpaceOverlay, use ortho-camera.
if (!_orthoCamera)
{
_orthoCamera = GetComponentInChildren<Camera>();
// Find existing ortho-camera.
foreach (Transform child in transform)
{
var cam = child.GetComponent<Camera>();
if (cam && cam.name == "[generated] UIParticleOverlayCamera")
{
_orthoCamera = cam;
break;
}
}

// Create ortho-camera.
if (!_orthoCamera)
Expand Down

0 comments on commit c42f8c8

Please sign in to comment.