Example #1
0
 private void DeleteCacheFiles()
 {
     for (int i = 0; i < ThreadNum; i++)
     {
         FileInfo info = new FileInfo(FileNames[i]);
         C_DebugHelper.LogFormat("Delete File {0} OK!", FileNames[i]);
         info.Delete();
     }
 }
Example #2
0
        public static T LoadAssetBundle <T>(string resName, string assetBundleFilePath, List <string> dpsList, bool isInstantiate = false, bool isForever = false) where T : UnityEngine.Object
        {
            if (string.IsNullOrEmpty(resName) || string.IsNullOrEmpty(assetBundleFilePath))
            {
                return(null);
            }

            T result = null;

            try
            {
                C_AssetBundleRef[] abs = new C_AssetBundleRef[dpsList.Count];
                for (int i = 0; i < abs.Length; i++)
                {
                    C_DebugHelper.LogFormat("LoadResource abs[{0}]: {1}", i, dpsList[i]);

                    abs[i] = C_MonoSingleton <C_AssetBundleMgr> .GetInstance().LoadFromFile(dpsList[i], isForever);
                }

                C_AssetBundleRef bundle = C_MonoSingleton <C_AssetBundleMgr> .GetInstance().LoadFromFile(assetBundleFilePath, isForever);

                if (bundle != null)
                {
                    result = bundle.LoadAsset <T>(resName);

                    if (isInstantiate && result != null)
                    {
                        result = GameObject.Instantiate(result);
                    }

                    bundle.AutoUnload();
                }

                for (int i = 0; i < abs.Length; i++)
                {
                    if (abs[i] != null)
                    {
                        abs[i].AutoUnload();
                    }
                }
            }
            catch (Exception e)
            {
                C_DebugHelper.LogError("LoadAssetBundle : " + e);
            }

            return(result);
        }
Example #3
0
 public void GotoState(string name)
 {
     C_DebugHelper.LogFormat("C_GameStateCtrl Goto State {0}", name);
     m_GameState.ChangeState(name);
 }