using System.Collections; using System.Collections.Generic; using System.IO; using UnityEngine; using UnityGameFramework.Runtime; namespace GFMain { public class LocalConfigComponent : GameFrameworkComponent { private readonly Dictionary dic = new Dictionary(); protected override void Awake() { base.Awake(); string filePath = Path.Combine(Application.streamingAssetsPath, "LocalConfig.txt"); string[] strLines = File.ReadAllLines(filePath); for (int i = 0; i < strLines.Length; i++) { string line = strLines[i].Trim(); if (!line.StartsWith('#')) { var index = line.IndexOf(':'); if (index != -1) { dic.Add(line.Substring(0, index).Trim(), line.Substring(index + 1).Trim()); } } } } public string this[string key] { get { if (dic.ContainsKey(key)) { return dic[key]; } else { return null; } } } } }