static int Retain(IntPtr L)
    {
        try
        {
            int count = LuaDLL.lua_gettop(L);

            if (count == 1)
            {
                Tangzx.ABSystem.AssetBundleInfo obj = (Tangzx.ABSystem.AssetBundleInfo)ToLua.CheckObject <Tangzx.ABSystem.AssetBundleInfo>(L, 1);
                obj.Retain();
                return(0);
            }
            else if (count == 2)
            {
                Tangzx.ABSystem.AssetBundleInfo obj = (Tangzx.ABSystem.AssetBundleInfo)ToLua.CheckObject <Tangzx.ABSystem.AssetBundleInfo>(L, 1);
                UnityEngine.Object arg0             = (UnityEngine.Object)ToLua.CheckObject <UnityEngine.Object>(L, 2);
                obj.Retain(arg0);
                return(0);
            }
            else
            {
                return(LuaDLL.luaL_throw(L, "invalid arguments to method: Tangzx.ABSystem.AssetBundleInfo.Retain"));
            }
        }
        catch (Exception e)
        {
            return(LuaDLL.toluaL_exception(L, e));
        }
    }
    static int Require(IntPtr L)
    {
        try
        {
            int count = LuaDLL.lua_gettop(L);

            if (count == 2)
            {
                Tangzx.ABSystem.AssetBundleInfo obj = (Tangzx.ABSystem.AssetBundleInfo)ToLua.CheckObject <Tangzx.ABSystem.AssetBundleInfo>(L, 1);
                UnityEngine.Object arg0             = (UnityEngine.Object)ToLua.CheckObject <UnityEngine.Object>(L, 2);
                UnityEngine.Object o = obj.Require(arg0);
                ToLua.Push(L, o);
                return(1);
            }
            else if (count == 3)
            {
                Tangzx.ABSystem.AssetBundleInfo obj  = (Tangzx.ABSystem.AssetBundleInfo)ToLua.CheckObject <Tangzx.ABSystem.AssetBundleInfo>(L, 1);
                UnityEngine.Component           arg0 = (UnityEngine.Component)ToLua.CheckObject <UnityEngine.Component>(L, 2);
                bool arg1            = LuaDLL.luaL_checkboolean(L, 3);
                UnityEngine.Object o = obj.Require(arg0, arg1);
                ToLua.Push(L, o);
                return(1);
            }
            else
            {
                return(LuaDLL.luaL_throw(L, "invalid arguments to method: Tangzx.ABSystem.AssetBundleInfo.Require"));
            }
        }
        catch (Exception e)
        {
            return(LuaDLL.toluaL_exception(L, e));
        }
    }
 static int ResetLifeTime(IntPtr L)
 {
     try
     {
         ToLua.CheckArgsCount(L, 1);
         Tangzx.ABSystem.AssetBundleInfo obj = (Tangzx.ABSystem.AssetBundleInfo)ToLua.CheckObject <Tangzx.ABSystem.AssetBundleInfo>(L, 1);
         obj.ResetLifeTime();
         return(0);
     }
     catch (Exception e)
     {
         return(LuaDLL.toluaL_exception(L, e));
     }
 }
    static int Instantiate(IntPtr L)
    {
        try
        {
            int count = LuaDLL.lua_gettop(L);

            if (count == 1)
            {
                Tangzx.ABSystem.AssetBundleInfo obj = (Tangzx.ABSystem.AssetBundleInfo)ToLua.CheckObject <Tangzx.ABSystem.AssetBundleInfo>(L, 1);
                UnityEngine.GameObject          o   = obj.Instantiate();
                ToLua.PushSealed(L, o);
                return(1);
            }
            else if (count == 2)
            {
                Tangzx.ABSystem.AssetBundleInfo obj = (Tangzx.ABSystem.AssetBundleInfo)ToLua.CheckObject <Tangzx.ABSystem.AssetBundleInfo>(L, 1);
                bool arg0 = LuaDLL.luaL_checkboolean(L, 2);
                UnityEngine.GameObject o = obj.Instantiate(arg0);
                ToLua.PushSealed(L, o);
                return(1);
            }
            else if (count == 3)
            {
                Tangzx.ABSystem.AssetBundleInfo obj  = (Tangzx.ABSystem.AssetBundleInfo)ToLua.CheckObject <Tangzx.ABSystem.AssetBundleInfo>(L, 1);
                UnityEngine.Vector3             arg0 = ToLua.ToVector3(L, 2);
                UnityEngine.Quaternion          arg1 = ToLua.ToQuaternion(L, 3);
                UnityEngine.GameObject          o    = obj.Instantiate(arg0, arg1);
                ToLua.PushSealed(L, o);
                return(1);
            }
            else if (count == 4)
            {
                Tangzx.ABSystem.AssetBundleInfo obj  = (Tangzx.ABSystem.AssetBundleInfo)ToLua.CheckObject <Tangzx.ABSystem.AssetBundleInfo>(L, 1);
                UnityEngine.Vector3             arg0 = ToLua.ToVector3(L, 2);
                UnityEngine.Quaternion          arg1 = ToLua.ToQuaternion(L, 3);
                bool arg2 = LuaDLL.luaL_checkboolean(L, 4);
                UnityEngine.GameObject o = obj.Instantiate(arg0, arg1, arg2);
                ToLua.PushSealed(L, o);
                return(1);
            }
            else
            {
                return(LuaDLL.luaL_throw(L, "invalid arguments to method: Tangzx.ABSystem.AssetBundleInfo.Instantiate"));
            }
        }
        catch (Exception e)
        {
            return(LuaDLL.toluaL_exception(L, e));
        }
    }
 static int AddDependency(IntPtr L)
 {
     try
     {
         ToLua.CheckArgsCount(L, 2);
         Tangzx.ABSystem.AssetBundleInfo obj  = (Tangzx.ABSystem.AssetBundleInfo)ToLua.CheckObject <Tangzx.ABSystem.AssetBundleInfo>(L, 1);
         Tangzx.ABSystem.AssetBundleInfo arg0 = (Tangzx.ABSystem.AssetBundleInfo)ToLua.CheckObject <Tangzx.ABSystem.AssetBundleInfo>(L, 2);
         obj.AddDependency(arg0);
         return(0);
     }
     catch (Exception e)
     {
         return(LuaDLL.toluaL_exception(L, e));
     }
 }
    static int set_minLifeTime(IntPtr L)
    {
        object o = null;

        try
        {
            o = ToLua.ToObject(L, 1);
            Tangzx.ABSystem.AssetBundleInfo obj = (Tangzx.ABSystem.AssetBundleInfo)o;
            float arg0 = (float)LuaDLL.luaL_checknumber(L, 2);
            obj.minLifeTime = arg0;
            return(0);
        }
        catch (Exception e)
        {
            return(LuaDLL.toluaL_exception(L, e, o, "attempt to index minLifeTime on a nil value"));
        }
    }
    static int set_data(IntPtr L)
    {
        object o = null;

        try
        {
            o = ToLua.ToObject(L, 1);
            Tangzx.ABSystem.AssetBundleInfo obj  = (Tangzx.ABSystem.AssetBundleInfo)o;
            Tangzx.ABSystem.AssetBundleData arg0 = (Tangzx.ABSystem.AssetBundleData)ToLua.CheckObject <Tangzx.ABSystem.AssetBundleData>(L, 2);
            obj.data = arg0;
            return(0);
        }
        catch (Exception e)
        {
            return(LuaDLL.toluaL_exception(L, e, o, "attempt to index data on a nil value"));
        }
    }
    static int set_bundleName(IntPtr L)
    {
        object o = null;

        try
        {
            o = ToLua.ToObject(L, 1);
            Tangzx.ABSystem.AssetBundleInfo obj = (Tangzx.ABSystem.AssetBundleInfo)o;
            string arg0 = ToLua.CheckString(L, 2);
            obj.bundleName = arg0;
            return(0);
        }
        catch (Exception e)
        {
            return(LuaDLL.toluaL_exception(L, e, o, "attempt to index bundleName on a nil value"));
        }
    }
    static int set_onUnloaded(IntPtr L)
    {
        object o = null;

        try
        {
            o = ToLua.ToObject(L, 1);
            Tangzx.ABSystem.AssetBundleInfo obj = (Tangzx.ABSystem.AssetBundleInfo)o;
            Tangzx.ABSystem.AssetBundleInfo.OnUnloadedHandler arg0 = (Tangzx.ABSystem.AssetBundleInfo.OnUnloadedHandler)ToLua.CheckDelegate <Tangzx.ABSystem.AssetBundleInfo.OnUnloadedHandler>(L, 2);
            obj.onUnloaded = arg0;
            return(0);
        }
        catch (Exception e)
        {
            return(LuaDLL.toluaL_exception(L, e, o, "attempt to index onUnloaded on a nil value"));
        }
    }
    static int get_mainObject(IntPtr L)
    {
        object o = null;

        try
        {
            o = ToLua.ToObject(L, 1);
            Tangzx.ABSystem.AssetBundleInfo obj = (Tangzx.ABSystem.AssetBundleInfo)o;
            UnityEngine.Object ret = obj.mainObject;
            ToLua.Push(L, ret);
            return(1);
        }
        catch (Exception e)
        {
            return(LuaDLL.toluaL_exception(L, e, o, "attempt to index mainObject on a nil value"));
        }
    }
    static int get_isReady(IntPtr L)
    {
        object o = null;

        try
        {
            o = ToLua.ToObject(L, 1);
            Tangzx.ABSystem.AssetBundleInfo obj = (Tangzx.ABSystem.AssetBundleInfo)o;
            bool ret = obj.isReady;
            LuaDLL.lua_pushboolean(L, ret);
            return(1);
        }
        catch (Exception e)
        {
            return(LuaDLL.toluaL_exception(L, e, o, "attempt to index isReady on a nil value"));
        }
    }
    static int get_refCount(IntPtr L)
    {
        object o = null;

        try
        {
            o = ToLua.ToObject(L, 1);
            Tangzx.ABSystem.AssetBundleInfo obj = (Tangzx.ABSystem.AssetBundleInfo)o;
            int ret = obj.refCount;
            LuaDLL.lua_pushinteger(L, ret);
            return(1);
        }
        catch (Exception e)
        {
            return(LuaDLL.toluaL_exception(L, e, o, "attempt to index refCount on a nil value"));
        }
    }
    static int get_minLifeTime(IntPtr L)
    {
        object o = null;

        try
        {
            o = ToLua.ToObject(L, 1);
            Tangzx.ABSystem.AssetBundleInfo obj = (Tangzx.ABSystem.AssetBundleInfo)o;
            float ret = obj.minLifeTime;
            LuaDLL.lua_pushnumber(L, ret);
            return(1);
        }
        catch (Exception e)
        {
            return(LuaDLL.toluaL_exception(L, e, o, "attempt to index minLifeTime on a nil value"));
        }
    }
    static int get_data(IntPtr L)
    {
        object o = null;

        try
        {
            o = ToLua.ToObject(L, 1);
            Tangzx.ABSystem.AssetBundleInfo obj = (Tangzx.ABSystem.AssetBundleInfo)o;
            Tangzx.ABSystem.AssetBundleData ret = obj.data;
            ToLua.PushObject(L, ret);
            return(1);
        }
        catch (Exception e)
        {
            return(LuaDLL.toluaL_exception(L, e, o, "attempt to index data on a nil value"));
        }
    }
    static int get_bundleName(IntPtr L)
    {
        object o = null;

        try
        {
            o = ToLua.ToObject(L, 1);
            Tangzx.ABSystem.AssetBundleInfo obj = (Tangzx.ABSystem.AssetBundleInfo)o;
            string ret = obj.bundleName;
            LuaDLL.lua_pushstring(L, ret);
            return(1);
        }
        catch (Exception e)
        {
            return(LuaDLL.toluaL_exception(L, e, o, "attempt to index bundleName on a nil value"));
        }
    }
    static int get_onUnloaded(IntPtr L)
    {
        object o = null;

        try
        {
            o = ToLua.ToObject(L, 1);
            Tangzx.ABSystem.AssetBundleInfo obj = (Tangzx.ABSystem.AssetBundleInfo)o;
            Tangzx.ABSystem.AssetBundleInfo.OnUnloadedHandler ret = obj.onUnloaded;
            ToLua.Push(L, ret);
            return(1);
        }
        catch (Exception e)
        {
            return(LuaDLL.toluaL_exception(L, e, o, "attempt to index onUnloaded on a nil value"));
        }
    }
    static int set_isReady(IntPtr L)
    {
        object o = null;

        try
        {
            o = ToLua.ToObject(L, 1);
            Tangzx.ABSystem.AssetBundleInfo obj = (Tangzx.ABSystem.AssetBundleInfo)o;
            bool arg0 = LuaDLL.luaL_checkboolean(L, 2);
            obj.isReady = arg0;
            return(0);
        }
        catch (Exception e)
        {
            return(LuaDLL.toluaL_exception(L, e, o, "attempt to index isReady on a nil value"));
        }
    }
Esempio n. 18
0
        /// <summary>
        /// 卸载不用的
        /// </summary>
        public void UnloadUnusedBundle(bool force = false)
        {
            if (_isCurrentLoading == false || force)
            {
                List<string> keys = ListPool<string>.Get();
                keys.AddRange(_loadedAssetBundle.Keys);

                bool hasUnusedBundle = false;
                //一次最多卸载的个数,防止卸载过多太卡
                int unloadLimit = 20;
                int unloadCount = 0;

                do
                {
                    hasUnusedBundle = false;
                    for (int i = 0; i < keys.Count && !_isCurrentLoading && unloadCount < unloadLimit; i++)
                    {
                        if (_isCurrentLoading && !force)
                            break;

                        string key = keys[i];
                        AssetBundleInfo abi = _loadedAssetBundle[key];
                        if (abi.isUnused)
                        {
                            hasUnusedBundle = true;
                            unloadCount++;

                            this.RemoveBundleInfo(abi);

                            keys.RemoveAt(i);
                            i--;
                        }
                    }
                } while (hasUnusedBundle && !_isCurrentLoading && unloadCount < unloadLimit);

                ListPool<string>.Release(keys);
#if UNITY_EDITOR
                if (unloadCount > 0 && enableLog)
                {
                    Debug.Log("===>> Unload Count: " + unloadCount);
                }
#endif
            }
        }
Esempio n. 19
0
        /// <summary>
        /// 卸载不用的
        /// </summary>
        public void UnloadUnusedBundle(bool force = false)
        {
            if (_isCurrentLoading == false || force)
            {
                List <string> keys            = new List <string>(_loadedAssetBundle.Keys);
                bool          hasUnusedBundle = false;
                //一次最多卸载的个数,防止卸载过多太卡
                int unloadLimit = 20;
                int unloadCount = 0;

                do
                {
                    hasUnusedBundle = false;
                    for (int i = 0; i < keys.Count && !_isCurrentLoading && unloadCount < unloadLimit; i++)
                    {
                        if (_isCurrentLoading && !force)
                        {
                            break;
                        }

                        string          key = keys[i];
                        AssetBundleInfo abi = _loadedAssetBundle[key];
                        if (abi.isUnused)
                        {
                            hasUnusedBundle = true;
                            unloadCount++;

                            this.RemoveBundleInfo(abi);

                            i--;
                            keys.Remove(key);
                        }
                    }
                } while (hasUnusedBundle && !_isCurrentLoading && unloadCount < unloadLimit);
#if UNITY_EDITOR
                if (unloadCount > 0)
                {
                    Debug.Log("===>> Unload Count: " + unloadCount);
                    Resources.UnloadUnusedAssets();
                }
#endif
            }
        }
Esempio n. 20
0
        public virtual void Dispose()
        {
            UnloadBundle();

            var e = deps.GetEnumerator();

            while (e.MoveNext())
            {
                AssetBundleInfo dep = e.Current;
                dep.depChildren.Remove(this.bundleName);
                dep.Release();
            }
            deps.Clear();
            references.Clear();
            if (onUnloaded != null)
            {
                onUnloaded(this);
            }
        }
    static int _CreateTangzx_ABSystem_AssetBundleInfo(IntPtr L)
    {
        try
        {
            int count = LuaDLL.lua_gettop(L);

            if (count == 0)
            {
                Tangzx.ABSystem.AssetBundleInfo obj = new Tangzx.ABSystem.AssetBundleInfo();
                ToLua.PushObject(L, obj);
                return(1);
            }
            else
            {
                return(LuaDLL.luaL_throw(L, "invalid arguments to ctor method: Tangzx.ABSystem.AssetBundleInfo.New"));
            }
        }
        catch (Exception e)
        {
            return(LuaDLL.toluaL_exception(L, e));
        }
    }
Esempio n. 22
0
 internal void RemoveBundleInfo(AssetBundleInfo abi)
 {
     abi.Dispose();
     _loadedAssetBundle.Remove(abi.bundleName);
 }
 private void OnBundleUnload(AssetBundleInfo abi)
 {
     this.bundleInfo = null;
     this.state = LoadState.State_None;
 }
Esempio n. 24
0
 private void OnBundleUnload(AssetBundleInfo abi)
 {
     this.bundleInfo = null;
     this.state      = LoadState.State_None;
     this.prority    = 0;
 }
Esempio n. 25
0
 void OnDepComplete(AssetBundleInfo abi)
 {
     _currentLoadingDepCount--;
     this.CheckDepComplete();
 }
Esempio n. 26
0
 public void AddDependency(AssetBundleInfo target)
 {
     if (target != null && deps.Add(target))
     {
         target.Retain();
         target.depChildren.Add(this.bundleName);
     }
 }
Esempio n. 27
0
 internal void RemoveBundleInfo(AssetBundleInfo abi)
 {
     abi.Dispose();
     _loadedAssetBundle.Remove(abi.bundleName);
 }
Esempio n. 28
0
        internal AssetBundleInfo CreateBundleInfo(AssetBundleLoader loader, AssetBundleInfo abi = null, AssetBundle assetBundle = null)
        {
            if (abi == null)
                abi = new AssetBundleInfo();
            abi.bundleName = loader.bundleName.ToLower();
            abi.bundle = assetBundle;
            abi.data = loader.bundleData;

            _loadedAssetBundle[abi.bundleName] = abi;
            return abi;
        }