| 123456789101112131415161718192021222324252627282930313233343536373839404142434445 |
- using System.Collections;
- using System.Collections.Generic;
- using System.IO;
- using UnityEngine;
- using UnityGameFramework.Runtime;
- namespace GFMain
- {
- public class LocalConfigComponent : GameFrameworkComponent
- {
- private readonly Dictionary<string, string> dic = new Dictionary<string, string>();
- 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;
- }
- }
- }
- }
- }
|