源战役客户端
Nie możesz wybrać więcej, niż 25 tematów Tematy muszą się zaczynać od litery lub cyfry, mogą zawierać myślniki ('-') i mogą mieć do 35 znaków.

57 wiersze
2.1 KiB

1 miesiąc temu
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.IO;
  6. using System.Runtime.InteropServices;
  7. using UnityEngine;
  8. namespace LuaFramework
  9. {
  10. public static class INIReader
  11. {
  12. [DllImport("kernel32")]
  13. private static extern int GetPrivateProfileString(string section, string key, string def, StringBuilder retval, int size, string filePath);
  14. private static string Section = "AppConstConfig";
  15. public static string fileName = "engine.ini";
  16. public static void InitConfig()
  17. {
  18. if (Application.platform == RuntimePlatform.WindowsEditor || Application.platform == RuntimePlatform.WindowsPlayer)
  19. {
  20. if (IniReadValue("releaseMode").Equals("1"))
  21. {
  22. AppConst.DebugMode = false;
  23. AppConst.WindowDataPath += IniReadValue("customDataPath");
  24. }
  25. else
  26. {
  27. AppConst.StandaloneDebugMode = true;
  28. #if UNITY_EDITOR
  29. var useLocalResourceStr = IniReadValue("useLocalResource");
  30. if (useLocalResourceStr != "")
  31. AppConst.UseLocalResource = Int32.Parse(useLocalResourceStr);
  32. var printLoadLocalResStr = IniReadValue("printLoadLocalRes");
  33. if (printLoadLocalResStr != "")
  34. AppConst.PrintLoadLocalRes = Int32.Parse(printLoadLocalResStr);
  35. var useLocalPathCache = IniReadValue("useLocalPathCache");
  36. if (useLocalPathCache == "1")
  37. AppConst.IsUseLocalPathCache = true;
  38. #endif
  39. }
  40. }
  41. }
  42. public static string IniReadValue(string Key)
  43. {
  44. string iniPath = Application.dataPath + "/" + fileName;
  45. if (File.Exists(iniPath))
  46. {
  47. StringBuilder tag = new StringBuilder(100);
  48. GetPrivateProfileString(Section, Key, "default", tag, 100, iniPath);
  49. return tag.ToString();
  50. }
  51. return "";
  52. }
  53. }
  54. }