Пример #1
0
    static int LoadResourceAsync(IntPtr L)
    {
        try
        {
            ToLua.CheckArgsCount(L, 3);
            ResourceManager            obj       = (ResourceManager)ToLua.CheckObject(L, 1, typeof(ResourceManager));
            string                     arg0      = ToLua.CheckString(L, 2);
            Void_STR_UnityEngineObject arg1      = null;
            LuaTypes                   funcType3 = LuaDLL.lua_type(L, 3);

            if (funcType3 != LuaTypes.LUA_TFUNCTION)
            {
                arg1 = (Void_STR_UnityEngineObject)ToLua.CheckObject(L, 3, typeof(Void_STR_UnityEngineObject));
            }
            else
            {
                LuaFunction func = ToLua.ToLuaFunction(L, 3);
                arg1 = DelegateFactory.CreateDelegate(typeof(Void_STR_UnityEngineObject), func) as Void_STR_UnityEngineObject;
            }

            obj.LoadResourceAsync(arg0, arg1);
            return(0);
        }
        catch (Exception e)
        {
            return(LuaDLL.toluaL_exception(L, e));
        }
    }
Пример #2
0
 /// <summary>
 /// 异步加载资源,addRefCount: 是否缓存并增加引用计数器
 /// </summary>
 /// <param name="resourcePath"></param>
 public void LoadResourceAsync(string resourcePath, Void_STR_UnityEngineObject asyncCallBack = null)
 {
     if (loadingCallbackList.ContainsKey(resourcePath))
     {
         loadingCallbackList[resourcePath] += asyncCallBack;
     }
     else
     {
         loadingCallbackList.Add(resourcePath, null);
         loadingCallbackList[resourcePath] += asyncCallBack;
         LoadResourceAsync0(resourcePath);
     }
 }
Пример #3
0
    private void HandlerAsyncCallBack(string resourcePath, Object asset)
    {
        if (!loadingCallbackList.ContainsKey(resourcePath))
        {
            Debug.LogError("loadingCallbackList:" + resourcePath + " had be removed");
        }

        if (asset == null)
        {
            Debug.LogError("equest.asset null:" + resourcePath);
        }


        Void_STR_UnityEngineObject asyncCallBack = loadingCallbackList[resourcePath];

        loadingCallbackList.Remove(resourcePath);

        if (asyncCallBack != null)
        {
            asyncCallBack(resourcePath, asset);
        }
    }