using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.IO; using System.Runtime.InteropServices; using UnityEngine; namespace LuaFramework { public static class INIReader { [DllImport("kernel32")] private static extern int GetPrivateProfileString(string section, string key, string def, StringBuilder retval, int size, string filePath); private static string Section = "AppConstConfig"; public static string fileName = "engine.ini"; public static void InitConfig() { if (Application.platform == RuntimePlatform.WindowsEditor || Application.platform == RuntimePlatform.WindowsPlayer) { if (IniReadValue("releaseMode").Equals("1")) { AppConst.DebugMode = false; AppConst.WindowDataPath += IniReadValue("customDataPath"); } else { AppConst.StandaloneDebugMode = true; #if UNITY_EDITOR var useLocalResourceStr = IniReadValue("useLocalResource"); if (useLocalResourceStr != "") AppConst.UseLocalResource = Int32.Parse(useLocalResourceStr); var printLoadLocalResStr = IniReadValue("printLoadLocalRes"); if (printLoadLocalResStr != "") AppConst.PrintLoadLocalRes = Int32.Parse(printLoadLocalResStr); var useLocalPathCache = IniReadValue("useLocalPathCache"); if (useLocalPathCache == "1") AppConst.IsUseLocalPathCache = true; #endif } } } public static string IniReadValue(string Key) { string iniPath = Application.dataPath + "/" + fileName; if (File.Exists(iniPath)) { StringBuilder tag = new StringBuilder(100); GetPrivateProfileString(Section, Key, "default", tag, 100, iniPath); return tag.ToString(); } return ""; } } }