using System.Collections;
|
using System.Collections.Generic;
|
using UnityEngine;
|
|
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<string, List<Sprite>> faceDic = new Dictionary<string, List<Sprite>>();
|
|
public UIFrameMgr()
|
{
|
Init();
|
}
|
|
public void Init()
|
{
|
var dic = FaceConfig.GetValues();
|
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<Sprite> list = null;
|
faceDic.TryGetValue(cfg.name, out list);
|
if (list != null)
|
{
|
list.Add(sprite);
|
}
|
else
|
{
|
list = new List<Sprite>();
|
list.Add(sprite);
|
faceDic.Add(cfg.name, list);
|
}
|
}
|
}
|
}
|
}
|
|
public Dictionary<string,List<UnityEngine.Sprite>> GetAllFace()
|
{
|
return faceDic;
|
}
|
|
public List<UnityEngine.Sprite> GetDynamicFace(string key)
|
{
|
List<UnityEngine.Sprite> list = null;
|
faceDic.TryGetValue(key, out list);
|
return list;
|
}
|
|
public bool ContainsFace(string key)
|
{
|
return faceDic.ContainsKey(key);
|
}
|
|
}
|