Exemplo n.º 1
0
        static IEnumerator UF_IELoadSettingsFile(ConfigFile config, string settingFileName)
        {
            string filepath = GlobalPath.StreamingAssetsPath + "/" + settingFileName;

#if UNITY_EDITOR || UNITY_IPHONE || UNITY_STANDALONE
            WWW www = new WWW("file://" + filepath);
#elif UNITY_ANDROID
            WWW www = new WWW(filepath);
#endif
            yield return(www);

            if (string.IsNullOrEmpty(www.error))
            {
                //检查配置是否加密
                var    bytedata = GHelper.UF_BytesCopy(www.bytes);
                string chunk    = System.Text.Encoding.UTF8.GetString(bytedata, 0, Mathf.Min(bytedata.Length, 8)).Trim();
                if (chunk.StartsWith("[", System.StringComparison.Ordinal) || chunk.StartsWith("#", System.StringComparison.Ordinal))
                {
                    Debugger.UF_Log("No need to encryp setting file:" + settingFileName);
                }
                else
                {
                    Debugger.UF_Log(string.Format("Encryp setting file[{0}] with key[{1}]", settingFileName, ConfigEncBKey));
                    GHelper.UF_BytesKey(bytedata, ConfigEncBKey);
                }
                System.IO.MemoryStream ms = new System.IO.MemoryStream(bytedata);
                config.UF_OpenReader(new System.IO.StreamReader(ms));
            }
            else
            {
                Debugger.UF_Warn(string.Format("IELoadSettingsFile:[{0}]  error:[{1}] ", filepath, www.error));
            }
            www.Dispose();
        }