初学 C#,直接上手项目。然后碰到这个问题。
//dll 引用的代码[从元数据]
public class WorldMgr : Il2CppSystem.Object
{
public WorldMgr();
public WorldMgr(System.IntPtr value);
public WorldUnitMgr unit { get; set; }
public WorldUnitBase playerUnit { get; set; }
}
//我编写的调用类方法
WorldMgr wm = new WorldMgr();
Debug.Log( wm.unit ) //√ 可以正常返回类型
Debug.Log( wm.playerUnit ) //× 提示 Object reference not set to an instance of an object
折腾了快 2 天了。不知道哪里出错了。。头疼。
我看 WorldUnitMgr 也没声明,为什么他可以。而我的 playerUnit 就提示没声明。。哭~