private static int LoadConfig(IntPtr L) { int result; try { ToLua.CheckArgsCount(L, 1); string configContent = ToLua.CheckString(L, 1); User_Config.LoadConfig(configContent); result = 0; } catch (Exception e) { result = LuaDLL.toluaL_exception(L, e, null); } return(result); }
void LoadConfig() { // first check local config exists or not string content = string.Empty; if (!AppConst.DebugMode && !Directory.Exists(Util.DataPath)) { Directory.CreateDirectory(Util.DataPath); } string config_path = Util.DataPath + "/config.txt"; if (FileManager.FileExist(config_path)) { content = FileManager.ReadFileString(config_path); } else { TextAsset obj = Resources.Load <TextAsset>("config"); #if UNITY_EDITOR if (obj == null) { File.Copy("Assets/config.txt.example", "Assets/Resources/config.txt", true); UnityEditor.AssetDatabase.Refresh(); obj = Resources.Load <TextAsset>("config"); } #else if (obj == null) { MessageBox.Show(UpdateTips.NO_CONFIG_VIA_MOBLIEPLATFORM, (int)MessageBox.Style.OkOnly, (go) => { Application.Quit(); }); } #endif content = obj.text; #if !UNITY_EDITOR FileManager.WriteFile(config_path, content); #endif } // load config User_Config.LoadConfig(content); User_Config.LoadGlobalSetting(); #if UNITY_IOS && !UNITY_EDITOR // iphone 6及以下强行设置为流畅 否则可能出现内存问题闪退 try { string deviceVersion = SystemInfo.deviceModel; Debug.Log(deviceVersion); if (!string.IsNullOrEmpty(deviceVersion)) { string[] tmps = deviceVersion.Split(','); Debug.Assert(tmps.Length == 2); int iVer = Convert.ToInt32(tmps[0].Substring(tmps[0].Length - 1, 1)); if (iVer < 7 || (iVer == 7 && tmps[1].Equals("iPhone7,2"))) { Debug.Log("iphone version < iphone6, set quality to 0"); User_Config.quality = 0; } } } catch (Exception e) { Debug.LogException(e); } #endif }