Example #1
0
        public override void OnImportAsset(AssetImportContext ctx)
        {
            byte[] data = Tools.Load(ctx.assetPath);
            string json = System.Text.UTF8Encoding.UTF8.GetString(data);

            LitJson.JsonData jsonData = Tools.DeserializeObject(json);
            mJsonList = new List <StringStringDictionary>();
            for (int i = 0; i < jsonData.Count; i++)
            {
                LitJson.JsonData       tmp  = jsonData[i];
                StringStringDictionary dict = new StringStringDictionary();
                IEnumerator            ite  = jsonData[i].Keys.GetEnumerator();
                while (ite.MoveNext())
                {
                    string key   = ite.Current.ToString();
                    string value = tmp[key].ToString();
                    dict.Add(key, value);
                }
                mJsonList.Add(dict);
            }

            string fileName = Path.GetFileNameWithoutExtension(ctx.assetPath);
            Object asset    = AssetDatabase.LoadAssetAtPath(ctx.assetPath, typeof(Object));

            ctx.AddObjectToAsset(fileName, asset);
            ctx.SetMainObject(asset);
        }
        //取得Bundle的MD5編號
        private static string GetMd5Unity(string path, string name)
        {
            FileInfo info = new FileInfo(path + name);

            byte[] data = Tools.Load(path, name.Replace(info.Extension, ".crc"));

            if (data == null)
            {
                return(string.Empty);
            }

            //取出Json字串
            string json = System.Text.UTF8Encoding.UTF8.GetString(data);
            //Json反序列化
            rCRC crc = Tools.DeserializeObject <rCRC>(json);

            return(crc.CRC.ToString());
        }
Example #3
0
        //取得下載列表
        private static List <rRes> GetDownloadList(eLanguage lang)
        {
            List <rRes> list = new List <rRes>();

            byte[] data    = null;
            rRes[] resData = null;
            string json    = string.Empty;
            string path    = Application.dataPath + "/" + Setting.DownloadAssetsFolder + "/" + GetLangPath(lang, true) + "Versions/";

            if (Setting.VersionItems == null || Setting.VersionItems.Count == 0)
            {
                data = Tools.Load(path, "Main.res", Setting.EncryptionKeyValue);
                if (data != null)
                {
                    json    = System.Text.UTF8Encoding.UTF8.GetString(data);
                    resData = Tools.DeserializeObject <rRes[]>(json);
                    for (int i = 0; i < resData.Length; i++)
                    {
                        list.Add(resData[i]);
                    }
                }
            }
            else
            {
                for (int i = 0; i < Setting.VersionItems.Count; i++)
                {
                    data = Tools.Load(path, Setting.VersionItems[i].ver, Setting.EncryptionKeyValue);
                    if (data != null)
                    {
                        json    = System.Text.UTF8Encoding.UTF8.GetString(data);
                        resData = Tools.DeserializeObject <rRes[]>(json);
                        for (int j = 0; j < resData.Length; j++)
                        {
                            list.Add(resData[j]);
                        }
                    }
                }
            }
            return(list);
        }