This commit is contained in:
陈思海 2026-03-18 15:01:36 +08:00
parent b9c79e16a5
commit fd46223352
4 changed files with 4 additions and 19 deletions

View File

@ -19,8 +19,6 @@ namespace UnityEngine
Object.Destroy(obj);
#endif
}
private static readonly List<Transform> s_CachedTransforms = new List<Transform>();
/// <summary>
/// 获取或增加组件。
/// </summary>
@ -83,20 +81,5 @@ namespace UnityEngine
return gameObject.scene.name != null;
}
/// <summary>
/// 递归设置游戏对象的层次。
/// </summary>
/// <param name="gameObject"><see cref="GameObject" /> 对象。</param>
/// <param name="layer">目标层次的编号。</param>
public static void SetLayerRecursively(this GameObject gameObject, int layer)
{
gameObject.GetComponentsInChildren(true, s_CachedTransforms);
foreach (var tf in s_CachedTransforms)
{
tf.gameObject.layer = layer;
}
s_CachedTransforms.Clear();
}
}
}

View File

@ -3,6 +3,7 @@ using System.Globalization;
using System.Collections.Generic;
using System.Text.RegularExpressions;
using AlicizaX;
using UnityEngine;
using UnityEngine.UI;
@ -10,7 +11,7 @@ using UnityEngine.UI;
using UnityEditor;
#endif
namespace AlicizaX
namespace UnityEngine
{
public static class GameHelper
{

View File

@ -2,7 +2,7 @@ using UnityEngine;
using UnityEngine.Rendering;
using UnityEngine.SceneManagement;
namespace AlicizaX
namespace UnityEngine
{
/// <summary>
/// 游戏对象帮助类

View File

@ -1,4 +1,5 @@
using System;
using UnityEngine;
namespace AlicizaX
{