22 lines
422 B
C#
22 lines
422 B
C#
using System;
|
|
#if UNITY
|
|
using UnityEngine;
|
|
|
|
namespace ET
|
|
{
|
|
public static class GameObjectHelper
|
|
{
|
|
public static T Get<T>(this GameObject gameObject, string key) where T : class
|
|
{
|
|
try
|
|
{
|
|
return gameObject.GetComponent<ReferenceCollector>().Get<T>(key);
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
throw new Exception($"获取{gameObject.name}的ReferenceCollector key失败, key: {key}", e);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
#endif |