/// <summary> /// 用Prefab创建一个Widget /// </summary> public TezBaseWidget createWidget(TezBaseWidget prefab, RectTransform parent, TezWidgetLife life) { TezBaseWidget widget = null; switch (life) { case TezWidgetLife.Normal: widget = Instantiate(prefab, parent, false); break; case TezWidgetLife.TypeOnly: var type = prefab.GetType(); if (m_WidgetWithType.TryGetValue(type, out widget)) { widget.reset(); return(widget); } else { widget = Instantiate(prefab, parent, false); m_WidgetWithType.Add(type, widget); } break; default: break; } widget.life = life; return(widget); }
public void removeTypeOnlyWidget(TezBaseWidget widget) { m_WidgetWithType.Remove(widget.GetType()); }