Skip to content

Commit

Permalink
fix: generated GameObject will be named '[generated] *'
Browse files Browse the repository at this point in the history
These objects are automatically generated and are not stored in the scene or prefab (HideFlags.DontSave)
  • Loading branch information
mob-sakai committed Aug 18, 2023
1 parent 821f08f commit 9b2e5c1
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
8 changes: 5 additions & 3 deletions Scripts/UIParticle.cs
Original file line number Diff line number Diff line change
Expand Up @@ -572,20 +572,22 @@ private Camera GetBakeCamera()
{
if (!canvas) return Camera.main;

// Render mode is not ScreenSpaceOverlay, use world camera.
// When render mode is ScreenSpaceCamera or WorldSpace, use world camera.
var root = canvas.rootCanvas;
if (root.renderMode != RenderMode.ScreenSpaceOverlay)
{
return root.worldCamera ? root.worldCamera : Camera.main;
}

// Create ortho-camera.
// When render mode is ScreenSpaceOverlay, use ortho-camera.
if (!_orthoCamera)
{
_orthoCamera = GetComponentInChildren<Camera>();

// Create ortho-camera.
if (!_orthoCamera)
{
var go = new GameObject("UIParticleOverlayCamera") { hideFlags = HideFlags.DontSave };
var go = new GameObject("[generated] UIParticleOverlayCamera") { hideFlags = HideFlags.DontSave };
go.SetActive(false);
go.transform.SetParent(transform, false);
_orthoCamera = go.AddComponent<Camera>();
Expand Down
2 changes: 1 addition & 1 deletion Scripts/UIParticleRenderer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ protected override void OnDisable()
public static UIParticleRenderer AddRenderer(UIParticle parent, int index)
{
// Create renderer object.
var go = new GameObject("UIParticleRenderer", typeof(UIParticleRenderer))
var go = new GameObject("[generated] UIParticleRenderer", typeof(UIParticleRenderer))
{
hideFlags = HideFlags.DontSave,
layer = parent.gameObject.layer
Expand Down

0 comments on commit 9b2e5c1

Please sign in to comment.