using System.Collections; using System.Collections.Generic; using UnityEngine; using TableConfig; public class UIFrameMgr { private static UIFrameMgr _inst = null; public static UIFrameMgr Inst { get { if (_inst == null) { _inst = new UIFrameMgr(); } return _inst; } } private readonly string FRAME_UIFOLDER = "Frame"; private Dictionary> faceDic = new Dictionary>(); public UIFrameMgr() { Init(); } public void Init() { var dic = Config.Instance.GetAllValues(); foreach (var cfg in dic) { for (int i = 1; i <= cfg.frameCnt; i++) { Sprite sprite = UILoader.LoadSprite(FRAME_UIFOLDER, StringUtility.Contact(cfg.name, "_", i)); if (sprite != null) { List list = null; faceDic.TryGetValue(cfg.name, out list); if (list != null) { list.Add(sprite); } else { list = new List(); list.Add(sprite); faceDic.Add(cfg.name, list); } } } } } public Dictionary> GetAllFace() { return faceDic; } public List GetDynamicFace(string key) { List list = null; faceDic.TryGetValue(key, out list); return list; } public bool ContainsFace(string key) { return faceDic.ContainsKey(key); } }