Esempio n. 1
0
    /// <summary>
    /// 异步
    /// </summary>
    /// <param name="abPath"></param>
    /// <param name="assetName"></param>
    /// <param name="atlas"></param>
    /// <param name="createDlg"></param>
    /// <param name="custParam"></param>
    public void GetCMResourceAsyn(ref CMResAsynSeedData <T> seedData, CMResEvent <T> createDlg, object param1 = null, object param2 = null, object param3 = null)
    {
        StructCMResAsynSeedData(ref seedData);
        AddRef();
        if (IsReady())
        {
            ChangeState(CMResState.CMRS_Active);
            if (null != createDlg)
            {
                createDlg.Invoke(GetThis(), param1, param2, param3);
            }
        }
        else
        {
            if (!m_dlgs.ContainsKey(seedData.Seed))
            {
                m_dlgs.Add(seedData.Seed, new CMEventBaseDelegate <T>()
                {
                    Dlg    = createDlg,
                    Param1 = param1,
                    Param2 = param2,
                    Param3 = param3,
                });
            }

            if (State != CMResState.CMRS_Loading)
            {
                ChangeState(CMResState.CMRS_Loading);
                DataManager.Manager <CMAssetBundleLoaderMgr>().CreateAssetAsyn(false, AbPath, AssetName, OnLoadAssetComplte, param1, param2, param3);
            }
        }
    }
Esempio n. 2
0
    /// <summary>
    /// 获取游戏对象(异步)
    /// </summary>
    /// <param name="abPath"></param>
    /// <param name="assetName"></param>
    /// <param name="obj"></param>
    /// <param name="createDlg"></param>
    /// <param name="custParam"></param>
    /// <returns></returns>
    public bool GetGameObjAsyn(string abPath, string assetName, CMResEvent <CMObj> createDlg, object param1 = null, object param2 = null, object param3 = null)
    {
        CMObj cmObj = null;

        if (!m_objs.TryGetValue(assetName, out cmObj))
        {
            cmObj = new CMObj(abPath, assetName);
            m_objs.Add(assetName, cmObj);
        }
        cmResAsynSeed = null;
        cmObj.GetCMResourceAsyn(ref cmResAsynSeed, createDlg, param1, param2, param3);
        return(true);
    }
Esempio n. 3
0
    /// <summary>
    ///
    /// </summary>
    /// <param name="resID"></param>
    /// <param name="tsEvent"></param>
    /// <param name="param"></param>
    public void SpawnObjAsyn(uint resID, CMResEvent <Transform> tsEvent, object param1 = null, object param2 = null, object param3 = null)
    {
        table.UIResourceDataBase rsDb = GameTableManager.Instance.GetTableItem <table.UIResourceDataBase>(resID);
        if (null == rsDb)
        {
            if (null != tsEvent)
            {
                tsEvent.Invoke(null, param1, param2, param3);
            }
            return;
        }

        CMObjPool pool = null;

        if (m_pools.TryGetValue(rsDb.resRelativePath, out pool) && pool.State != CMObjPool.CMObjPoolState.Release)
        {
            if (null != tsEvent)
            {
                tsEvent.Invoke(pool.SpawnInstance(Vector3.zero, Quaternion.identity, true), param1, param2, param3);
            }
        }
        else
        {
            if (null != pool)
            {
                pool = null;
                RemovePool(rsDb.resRelativePath);
            }
            DataManager.Manager <CMResourceMgr>().GetGameObjAsyn(rsDb.assetbundlePath, rsDb.resRelativePath, (obj, passParam1, passParam2, passParam3) =>
            {
                CMObjPool newpool = CreatePool(
                    rsDb.resRelativePath
                    , obj.GetGameObj().transform
                    , rsDb.resKeepType != 2
                    , (int)rsDb.resPreloadNum
                    , (int)rsDb.resCloneNumLimit
                    , (rsDb.releaseCullAboveMask != 0)
                    , (int)rsDb.releaseCullAboveNum
                    , (int)rsDb.resIdleKeepNum
                    , rsDb.idle2releaseTime
                    , rsDb.active2idleTime
                    , (rsDb.cloneAddScriptState == 1) ? rsDb.resName : "");
                if (null != tsEvent)
                {
                    tsEvent.Invoke(newpool.SpawnInstance(Vector3.zero, Quaternion.identity), passParam1, passParam2, passParam3);
                }
            }, param1, param2, param3);
        }
    }
Esempio n. 4
0
    /// <summary>
    /// 获取字体(异步)
    /// </summary>
    /// <param name="abPath"></param>
    /// <param name="assetName"></param>
    /// <param name="font"></param>
    /// <param name="createDlg"></param>
    /// <param name="custParam"></param>
    /// <returns></returns>
    public bool GetFontAsyn(string abPath, string assetName, ref CMResAsynSeedData <CMFont> seedData, CMResEvent <CMFont> createDlg, float timeIdleStateKeep = 120, float timeRelaseStateKeep = 10, object param1 = null, object param2 = null, object param3 = null)
    {
        CMFont cmfont = null;

        if (!m_fonts.TryGetValue(assetName, out cmfont))
        {
            cmfont = new CMFont(abPath, assetName, timeIdleStateKeep, timeRelaseStateKeep);
            m_fonts.Add(assetName, cmfont);
        }
        cmfont.GetCMResourceAsyn(ref seedData, createDlg, param1, param2, param3);
        return(true);
    }
Esempio n. 5
0
    /// <summary>
    /// 获取贴图(异步)
    /// </summary>
    /// <param name="resID"></param>
    /// <param name="tex"></param>
    /// <param name="te"></param>
    /// <param name="param"></param>
    private static void GetTextureAsyn(uint resID, ref CMResAsynSeedData <CMTexture> seedData, CMResEvent <CMTexture> te, object param1 = null, object param2 = null, object param3 = null)
    {
        table.UIResourceDataBase rsDb = GameTableManager.Instance.GetTableItem <table.UIResourceDataBase>(resID);
        if (null == rsDb)
        {
            if (null != te)
            {
                te.Invoke(null, param1, param2, param3);
            }
            return;
        }

        DataManager.Manager <CMResourceMgr>().GetTextureAsyn(rsDb.assetbundlePath, rsDb.resRelativePath,
                                                             ref seedData, te,
                                                             rsDb.idle2releaseTime, 10f,
                                                             param1, param2, param3);
    }
Esempio n. 6
0
 /// <summary>
 /// 获取对象(异步)
 /// </summary>
 /// <param name="resID">资源ID</param>
 /// <param name="te">回调</param>
 /// <param name="param">参数</param>
 public static void GetObjAsyn(uint resID, CMResEvent <Transform> te, object param1 = null, object param2 = null, object param3 = null)
 {
     DataManager.Manager <CMObjPoolManager>().SpawnObjAsyn(resID, te, param1, param2, param3);
 }
Esempio n. 7
0
    //public static CMAtlas GetAtlas(AtlasID atlasID)
    //{
    //    return GetAtlas((uint)atlasID);
    //}
    #endregion

    #region Font
    /// <summary>
    ///  获取字图(异步)
    /// </summary>
    /// <param name="resID"></param>
    /// <param name="font"></param>
    /// <param name="fe"></param>
    /// <param name="param"></param>
    public static void GetFontAsyn(uint resID, ref CMResAsynSeedData <CMFont> seedData, CMResEvent <CMFont> fe, object param = null)
    {
        table.UIResourceDataBase rsDb = GameTableManager.Instance.GetTableItem <table.UIResourceDataBase>(resID);
        if (null == rsDb)
        {
            if (null != fe)
            {
                fe.Invoke(null, param, null, null);
            }
            return;
        }

        DataManager.Manager <CMResourceMgr>().GetFontAsyn(rsDb.assetbundlePath, rsDb.resRelativePath, ref seedData, fe, rsDb.idle2releaseTime, 10, param);
    }
Esempio n. 8
0
 /// <summary>
 /// 获取图集(异步)
 /// </summary>
 /// <param name="resID"></param>
 /// <param name="atlas"></param>
 /// <param name="ae"></param>
 /// <param name="param"></param>
 public static void GetAtlasAsyn(uint resID, ref CMResAsynSeedData <CMAtlas> seedData, CMResEvent <CMAtlas> createDlg,
                                 object param1 = null, object param2 = null, object param3 = null)
 {
     table.UIResourceDataBase rsDb = GameTableManager.Instance.GetTableItem <table.UIResourceDataBase>(resID);
     if (null == rsDb)
     {
         if (null != createDlg)
         {
             createDlg.Invoke(null, param1, param2, param3);
         }
         return;
     }
     DataManager.Manager <CMResourceMgr>().GetAtlasAsyn(rsDb.assetbundlePath, rsDb.resRelativePath,
                                                        ref seedData, createDlg,
                                                        rsDb.idle2releaseTime, 10
                                                        , param1, param2, param3);
 }