예제 #1
0
 static int CreateGameObjectAsync(IntPtr L)
 {
     try
     {
         ToLua.CheckArgsCount(L, 3);
         int    arg0 = (int)LuaDLL.luaL_checknumber(L, 1);
         string arg1 = ToLua.CheckString(L, 2);
         GameObjectPool.OnCreateGameObject arg2 = (GameObjectPool.OnCreateGameObject)ToLua.CheckDelegate <GameObjectPool.OnCreateGameObject>(L, 3);
         int o = ResourceUtil.CreateGameObjectAsync(arg0, arg1, arg2);
         LuaDLL.lua_pushinteger(L, o);
         return(1);
     }
     catch (Exception e)
     {
         return(LuaDLL.toluaL_exception(L, e));
     }
 }
예제 #2
0
    void CreateGameObject()
    {
        int requestId = ResourceUtil.CreateGameObjectAsync(1, pname, (int tInstanceId, int tRequestId) => {
            Debug.Log("==========================load gameObject success " + pname);
            GameObject obj       = GameObjectPool.GetGameObject(tInstanceId);
            obj.transform.parent = transform;
            // 卸载
            if (createState == CreateState.Destory)
            {
                ResourceUtil.DestoryGameObject(tInstanceId);
            }
        });

        // 取消加载
        if (createState == CreateState.Cancel)
        {
            ResourceUtil.CancelCreateGameObjectAsync(requestId);
        }
    }