源码网商城,靠谱的源码在线交易网站 我的订单 购物车 帮助

源码网商城

C#嵌套类的访问方法

  • 时间:2021-03-07 14:53 编辑: 来源: 阅读:
  • 扫一扫,手机访问
摘要:C#嵌套类的访问方法
对于以下数据,如何在运行时通过字符串来得到静态变量UIPath的值。
[u]复制代码[/u] 代码如下:
public class GameMainMenu : UIClass {     public class JetPack : UIClass     {         public static UIPath UIPath = new UIPath("UIPrefabs/GameMainMenu/JetPack/JetPack.prefab");     } }
像下面这样即可。
[u]复制代码[/u] 代码如下:
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());
  • 全部评论(0)
联系客服
客服电话:
400-000-3129
微信版

扫一扫进微信版
返回顶部