C#嵌套类的访问方法
摘要:对于以下数据,如何在运行时通过字符串来得到静态变量UIPath的值。复制代码代码如下:publicclassGameMainMenu:UIC...
对于以下数据,如何在运行时通过字符串来得到静态变量UIPath的值。
复制代码 代码如下:
public class GameMainMenu : UIClass
{
public class JetPack : UIClass
{
public static UIPath UIPath = new UIPath("UIPrefabs/GameMainMenu/JetPack/JetPack.prefab");
}
}
像下面这样即可。
复制代码 代码如下:
BindingFlags flag = BindingFlags.Static | BindingFlags.Public;
Type type = Type.GetType("GameMainMenu+JetPack");
System.Reflection.FieldInfo key = type.GetField("UIPath", flag);
Debug.Log((key.GetValue(null) as UIPath).ToString());
【C#嵌套类的访问方法】相关文章:
上一篇:
C#检测是否有u盘插入的方法
下一篇:
C#实现在控制台输出当前系统时间的方法