//NOWGF
        /// <summary>
        /// 异步加载资源包。
        /// </summary>
        /// <param name="assetBundleName">要加载资源包的名称。</param>
        /// <param name="loadAssetBundleCallbacks">加载资源包回调函数集。</param>
        /// <param name="userData">用户自定义数据。</param>
        public void LoadAssetBundle(string assetBundleName, LoadAssetBundleCallbacks loadAssetBundleCallbacks, object userData)
        {
            if (string.IsNullOrEmpty(assetBundleName))
            {
                throw new GameFrameworkException("AssetBundle name is invalid.");
            }

            if (loadAssetBundleCallbacks == null)
            {
                throw new GameFrameworkException("Load assetbundle callbacks is invalid.");
            }

            m_ResourceLoader.LoadAssetBundle(assetBundleName, loadAssetBundleCallbacks, userData);
        }
Exemple #2
0
 static int LoadAssetBundle(IntPtr L)
 {
     try
     {
         ToLua.CheckArgsCount(L, 4);
         UnityGameFramework.Runtime.ResourceComponent obj = (UnityGameFramework.Runtime.ResourceComponent)ToLua.CheckObject(L, 1, typeof(UnityGameFramework.Runtime.ResourceComponent));
         string arg0 = ToLua.CheckString(L, 2);
         GameFramework.Resource.LoadAssetBundleCallbacks arg1 = (GameFramework.Resource.LoadAssetBundleCallbacks)ToLua.CheckObject(L, 3, typeof(GameFramework.Resource.LoadAssetBundleCallbacks));
         object arg2 = ToLua.ToVarObject(L, 4);
         obj.LoadAssetBundle(arg0, arg1, arg2);
         return(0);
     }
     catch (Exception e)
     {
         return(LuaDLL.toluaL_exception(L, e));
     }
 }
    static int set_m_loadAssetBundleCallbacks(IntPtr L)
    {
        object o = null;

        try
        {
            o = ToLua.ToObject(L, 1);
            UnityGameFramework.Runtime.ListLoader           obj  = (UnityGameFramework.Runtime.ListLoader)o;
            GameFramework.Resource.LoadAssetBundleCallbacks arg0 = (GameFramework.Resource.LoadAssetBundleCallbacks)ToLua.CheckObject(L, 2, typeof(GameFramework.Resource.LoadAssetBundleCallbacks));
            obj.m_loadAssetBundleCallbacks = arg0;
            return(0);
        }
        catch (Exception e)
        {
            return(LuaDLL.toluaL_exception(L, e, o == null ? "attempt to index m_loadAssetBundleCallbacks on a nil value" : e.Message));
        }
    }
    static int get_m_loadAssetBundleCallbacks(IntPtr L)
    {
        object o = null;

        try
        {
            o = ToLua.ToObject(L, 1);
            UnityGameFramework.Runtime.ListLoader           obj = (UnityGameFramework.Runtime.ListLoader)o;
            GameFramework.Resource.LoadAssetBundleCallbacks ret = obj.m_loadAssetBundleCallbacks;
            ToLua.PushObject(L, ret);
            return(1);
        }
        catch (Exception e)
        {
            return(LuaDLL.toluaL_exception(L, e, o == null ? "attempt to index m_loadAssetBundleCallbacks on a nil value" : e.Message));
        }
    }
            //NOWGF
            /// <summary>
            /// 异步加载资源包。
            /// </summary>
            /// <param name="assetBundleName">要加载资源包的名称。</param>
            /// <param name="loadAssetBundleCallbacks">加载资源包回调函数集。</param>
            /// <param name="userData">用户自定义数据。</param>
            public void LoadAssetBundle(string assetBundleName, LoadAssetBundleCallbacks loadAssetBundleCallbacks, object userData)
            {
                ResourceInfo?resourceInfo      = null;
                string       resourceChildName = null;

                if (!CheckAssetBundle(assetBundleName, out resourceInfo, out resourceChildName))
                {
                    string errorMessage = string.Format("Can not load asset bundle '{0}'.", assetBundleName);
                    if (loadAssetBundleCallbacks.LoadAssetBundleFailureCallback != null)
                    {
                        loadAssetBundleCallbacks.LoadAssetBundleFailureCallback(assetBundleName, LoadResourceStatus.NotReady, errorMessage, userData);
                        return;
                    }

                    throw new GameFrameworkException(errorMessage);
                }

                LoadAssetBundleTask mainTask = new LoadAssetBundleTask(assetBundleName, resourceInfo.Value, loadAssetBundleCallbacks, resourceChildName, userData);

                m_TaskPool.AddTask(mainTask);
            }