static int GetGameObjectAsync(IntPtr L) { try { ToLua.CheckArgsCount(L, 3); GameObjectPoolManager obj = (GameObjectPoolManager)ToLua.CheckObject(L, 1, typeof(GameObjectPoolManager)); string arg0 = ToLua.CheckString(L, 2); Void_UnityEngineObject arg1 = null; LuaTypes funcType3 = LuaDLL.lua_type(L, 3); if (funcType3 != LuaTypes.LUA_TFUNCTION) { arg1 = (Void_UnityEngineObject)ToLua.CheckObject(L, 3, typeof(Void_UnityEngineObject)); } else { LuaFunction func = ToLua.ToLuaFunction(L, 3); arg1 = DelegateFactory.CreateDelegate(typeof(Void_UnityEngineObject), func) as Void_UnityEngineObject; } obj.GetGameObjectAsync(arg0, arg1); return(0); } catch (Exception e) { return(LuaDLL.toluaL_exception(L, e)); } }
/// <summary> /// 异步获取资源,在回调函数里面返回资源对象 /// </summary> public void GetGameObjectAsync(string path, Void_UnityEngineObject finishCallback) { Object sourceObj = ResourceManager.Instance.GetResource(path); if (sourceObj != null) { GameObjectPoolManager.Instance.Regist(path, 1); GameObject obj = GameObjectPoolManager.Instance.Spawn(path); finishCallback(obj); } else { ResourceManager.Instance.LoadResourceAsync(path, (string resPath, UnityEngine.Object asset) => { GameObject obj = null; if (asset != null) { GameObjectPoolManager.Instance.Regist(path, 1); obj = GameObjectPoolManager.Instance.Spawn(path); } if (finishCallback != null) { finishCallback(obj); } }); } }