Пример #1
0
    static int GetRes(IntPtr L)
    {
        try
        {
            int count = LuaDLL.lua_gettop(L);

            if (count == 2)
            {
                QFramework.ResMgr        obj  = (QFramework.ResMgr)ToLua.CheckObject <QFramework.ResMgr>(L, 1);
                QFramework.ResSearchRule arg0 = (QFramework.ResSearchRule)ToLua.CheckObject <QFramework.ResSearchRule>(L, 2);
                QFramework.IRes          o    = obj.GetRes(arg0);
                ToLua.PushObject(L, o);
                return(1);
            }
            else if (count == 3)
            {
                QFramework.ResMgr        obj  = (QFramework.ResMgr)ToLua.CheckObject <QFramework.ResMgr>(L, 1);
                QFramework.ResSearchRule arg0 = (QFramework.ResSearchRule)ToLua.CheckObject <QFramework.ResSearchRule>(L, 2);
                bool            arg1          = LuaDLL.luaL_checkboolean(L, 3);
                QFramework.IRes o             = obj.GetRes(arg0, arg1);
                ToLua.PushObject(L, o);
                return(1);
            }
            else
            {
                return(LuaDLL.luaL_throw(L, "invalid arguments to method: QFramework.ResMgr.GetRes"));
            }
        }
        catch (Exception e)
        {
            return(LuaDLL.toluaL_exception(L, e));
        }
    }
Пример #2
0
 public override bool IsDone()
 {
     // 如果有依赖,要先判断依赖是否已经加载完成
     if (this.dependences != null)
     {
         for (int i = 0; i < this.dependences.Length; ++i)
         {
             if (!ResMgr.Instance().IsLoadedAssetBundle(this.dependences[i]))
             {
                 return(false);
             }
         }
     }
     // 判断自己是否加载完成
     if (base.LoadDoneCallback == null)
     {
         // 依赖资源,不需要LoadDone回调
         if (this.assetbundle != null)
         {
             return(true);
         }
         if (this.www.isDone)
         {
             this.assetbundle = this.www.assetBundle;
             this.www.Dispose();
             this.www = null;
             return(true);
         }
         return(false);
     }
     else
     {
         // 直接资源,需要LoadDone回调,所以需要从AssetBundle中提取资源对象
         if (this.assetbundleReq != null)
         {
             // 只有从assetbundle中提取出最终的资源对象,才算加载完成,保证所有的IO操作都是异步的
             return(this.assetbundleReq.isDone);
         }
         else
         {
             if (this.www.isDone)
             {
                 this.assetbundle = this.www.assetBundle;
                 // 从assetbundle中提取资源对象
                 string resPath = string.Format(LocalPath.AssetBundleFormation, base.ResName);
                 this.assetbundleReq = this.assetbundle.LoadAssetAsync(resPath);
                 this.www.Dispose();
                 this.www = null;
             }
             return(false);
         }
     }
 }
Пример #3
0
 /// <summary>
 /// 检查依赖资源是否已经加载完成,如果没有,则重新加载
 /// </summary>
 public virtual void CheckDependences()
 {
     this.dependences = ResMgr.Instance().GetDependences(base.ResName);
     for (int i = 0; i < this.dependences.Length; ++i)
     {
         string dependence = this.dependences[i];
         if (!ResMgr.Instance().IsLoadedAssetBundle(dependence))
         {
             ResMgr.Instance().LoadRes(dependence);
         }
     }
 }
Пример #4
0
 static int ClearOnUpdate(IntPtr L)
 {
     try
     {
         ToLua.CheckArgsCount(L, 1);
         QFramework.ResMgr obj = (QFramework.ResMgr)ToLua.CheckObject <QFramework.ResMgr>(L, 1);
         obj.ClearOnUpdate();
         return(0);
     }
     catch (Exception e)
     {
         return(LuaDLL.toluaL_exception(L, e));
     }
 }
Пример #5
0
 static int RemoveUnusedRes(IntPtr L)
 {
     try
     {
         ToLua.CheckArgsCount(L, 1);
         QFramework.ResMgr obj = (QFramework.ResMgr)ToLua.CheckObject <QFramework.ResMgr>(L, 1);
         obj.RemoveUnusedRes();
         return(0);
     }
     catch (Exception e)
     {
         return(LuaDLL.toluaL_exception(L, e));
     }
 }
Пример #6
0
 static int PushIEnumeratorTask(IntPtr L)
 {
     try
     {
         ToLua.CheckArgsCount(L, 2);
         QFramework.ResMgr          obj  = (QFramework.ResMgr)ToLua.CheckObject <QFramework.ResMgr>(L, 1);
         QFramework.IEnumeratorTask arg0 = (QFramework.IEnumeratorTask)ToLua.CheckObject <QFramework.IEnumeratorTask>(L, 2);
         obj.PushIEnumeratorTask(arg0);
         return(0);
     }
     catch (Exception e)
     {
         return(LuaDLL.toluaL_exception(L, e));
     }
 }
Пример #7
0
        public void PreloadMusic(string path, int id)
        {
            QTest.TimeBegan(path);

            ResMgr.Instance().LoadRes(path, delegate(string resName, Object resObj) {
                if (resObj)
                {
                    if (APP_CONFIG.DEBUG)
                    {
                        QPrint.Warn("loaded: " + path + " " + id.ToString() + "time:" + QTest.TimeStop(path));
                    }
                    musicClips[id] = resObj as AudioClip;
                }
            });
        }
Пример #8
0
    static int get_Count(IntPtr L)
    {
        object o = null;

        try
        {
            o = ToLua.ToObject(L, 1);
            QFramework.ResMgr obj = (QFramework.ResMgr)o;
            int ret = obj.Count;
            LuaDLL.lua_pushinteger(L, ret);
            return(1);
        }
        catch (Exception e)
        {
            return(LuaDLL.toluaL_exception(L, e, o, "attempt to index Count on a nil value"));
        }
    }
Пример #9
0
        // Use this for initialization
        private IEnumerator Start()
        {
            var loader = ResLoader.Allocate();

            ResMgr.Init();

            var spriteAtlas = loader.LoadSync <SpriteAtlas>("spriteatlas");
            var square      = spriteAtlas.GetSprite("Square");

            Log.I(spriteAtlas.spriteCount);

            mImage.sprite = square;

            yield return(new WaitForSeconds(5.0f));

            loader.Recycle2Cache();
            loader = null;
        }
Пример #10
0
 public override bool IsDone()
 {
     if (this.dependences != null)
     {
         for (int i = 0; i < this.dependences.Length; ++i)
         {
             if (!ResMgr.Instance().IsLoadedAssetBundle(this.dependences[i]))
             {
                 return(false);
             }
         }
     }
     if (this.op != null)
     {
         return(this.op.isDone);
     }
     else
     {
         if (this.www.isDone)
         {
             this.assetbundle = this.www.assetBundle;
             string scene = base.SceneName.Substring(0, base.SceneName.LastIndexOf('.'));
             if (this.additive)
             {
                 this.op = Application.LoadLevelAdditiveAsync(scene);
             }
             else
             {
                 this.op = Application.LoadLevelAsync(scene);
             }
             this.www.Dispose();
             this.www = null;
         }
         return(false);
     }
 }
Пример #11
0
 private void Awake()
 {
     ResMgr.Init();
 }
Пример #12
0
 public static IEnumerator InitAsync()
 {
     yield return(ResMgr.InitAsync());
 }
Пример #13
0
 public static void Init()
 {
     ResMgr.Init();
 }
Пример #14
0
 public static void AddSubProject(string projectName)
 {
     ResMgr.AddSubProject(projectName);
 }
Пример #15
0
 private void Awake()
 {
     ResMgr.Init();
     Log.Level = LogLevel.Max;
     PCConnectMobileManager.Instance.SendEvent(PCConnectMobileEvent.MobileServerCreated);
 }