Beispiel #1
0
        GameAssetConfig loadGameAssetConfig()
        {
            string fullpath = AssetBundleInfo.assetPath_local + "\\" + "gameAssetConfig.txt";

            fullpath = fullpath.Replace("/", "\\");
            if (File.Exists(fullpath))
            {
                StreamReader sr   = File.OpenText(fullpath);
                string       text = sr.ReadToEnd();
                sr.Close();
                return(GameAssetConfig.FromStr(text));
            }
            else
            {
                GameAssetConfig gac = null;
                TextAsset       ta  = Resources.Load <TextAsset>("gameAssetConfig") as TextAsset;
                if (ta != null)
                {
                    Debug.Log("textasset config is not null:" + ta.text);
                    gac = GameAssetConfig.FromStr(ta.text);
                }
                if (gac == null)
                {
                    Debug.LogError("GameAssetConfig file is not exsit!");
                }
                return(gac);
            }
        }
Beispiel #2
0
 public AssetBase()
 {
     gloabalSourceDic = new Dictionary <string, Object>();
     sceneSourceDic   = new Dictionary <string, Object>();
     curAssetVersion  = getAssetinfoFromLocal();
     abConfig         = loadABConfig();
     gameAssetConfig  = loadGameAssetConfig();
     if (curAssetVersion == null)
     {
         Debug.LogError("curAssetVersion null");
     }
     else
     {
         Debug.Log("本地资源版本号:" + curAssetVersion.assetVersion);
         //    AppFacade.Ins.Log(BugType.log, "本地资源版本号"+ curAssetVersion.assetVersion);
     }
     loader = new AssetBundleLoader();
 }
Beispiel #3
0
        /// <summary>
        /// 拉资源配置信息
        /// </summary>
        /// <param name="url"></param>
        /// <param name="back"></param>
        void pullAssetinfoFromSer(System.Action <AssetVersion> back)
        {
            string VersionPath         = AssetBundleInfo.assetPath_server + "/" + "assetVersionInfo.txt"; //资源版本信息
            string ConfigPath          = AssetBundleInfo.assetPath_server + "/" + "abConfig.txt";         //资源包配置信息
            string GameAssetConfigPath = AssetBundleInfo.assetPath_server + "/" + "gameAssetConfig.txt";  //游戏资源预加载信息

            loader.LoadFileFromServer(GameAssetConfigPath, (string str0) => {
                gameAssetConfig = GameAssetConfig.FromStr(str0);
                loader.LoadFileFromServer(ConfigPath, (string str) => {
                    Debug.Log("config file download"); abConfig = AssetbundleConfig.FromStr(str);
                    loader.LoadFileFromServer(VersionPath, (string str1) => {
                        AssetVersion av = AssetVersion.FromString(str1);
                        if (back != null)
                        {
                            back(av);
                        }
                    });
                });
            });
        }
Beispiel #4
0
        public static GameAssetConfig FromStr(string str)
        {
            List <string> ga = new List <string>();
            Dictionary <string, List <string> > sa = new Dictionary <string, List <string> >();

            string[] strs = str.Split(';');
            if (strs.Length == 0)
            {
                Debug.LogError("1"); return(null);
            }
            for (int k = 0; k < strs.Length; k++)
            {
                List <string> assetlist = new List <string>();
                string[]      gaAssets  = strs[k].Split('|');
                if (gaAssets.Length != 2)
                {
                    continue;
                }
                string[] assetArray = gaAssets[1].Split(',');
                for (int i = 0; i < assetArray.Length; i++)
                {
                    assetlist.Add(assetArray[i]);
                }
                if (k == 0)
                {
                    if (gaAssets[0] != "gameassets")
                    {
                        Debug.LogError("2"); return(null);
                    }
                    ga = assetlist;
                }
                else
                {
                    sa.Add(gaAssets[0], assetlist);
                }
            }
            GameAssetConfig config = new GameAssetConfig(ga, sa);

            return(config);
        }
Beispiel #5
0
        public static void Init()
        {
            string path1 = sourcePath + "/ForPackWithDependices";
            string path2 = sourcePath + "/ForPackWithNoDependices";

            if (!Directory.Exists(path1))
            {
                Directory.CreateDirectory(path1);
            }
            if (!Directory.Exists(path2))
            {
                Directory.CreateDirectory(path2);
            }
            TextAsset ta = Resources.Load <TextAsset>("gameAssetConfig");

            if (ta == null)
            {
                string str = new GameAssetConfig().ToStr();
                Debug.Log(str);
                FileHelper.CreateFile("D:/", "gameAssetConfig.txt", str, false);
                Debug.LogError("copy the file:" + "d:/gameAssetConfig.txt " + "to resources");
            }
        }