通过本文主要向大家介绍了c#嵌套类,c#嵌套,c#嵌套窗体,c#循环嵌套,c#命名空间可以嵌套吗等相关知识,希望对您有所帮助,也希望大家支持linkedu.com www.linkedu.com
对于以下数据,如何在运行时通过字符串来得到静态变量UIPath的值。
public class GameMainMenu : UIClass
{
public class JetPack : UIClass
{
public static UIPath UIPath = new UIPath("UIPrefabs/GameMainMenu/JetPack/JetPack.prefab");
}
}
</div>
像下面这样即可。
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());
</div>