using System.Collections.Generic; using FairyGUI; namespace GFGGame { public class RedDotController : SingletonBase { private List comRedDotPool = new List(); public void SetComRedDot(GComponent parentCom, bool isRed) { GComponent comRedDot; if (isRed) { if (parentCom.GetChild("comResDot") != null) return; if (comRedDotPool.Count > 0) { comRedDot = comRedDotPool[0]; comRedDotPool.RemoveAt(0); } else { comRedDot = UIPackage.CreateObject("CommonGame", "ComRedDot").asCom; } parentCom.AddChild(comRedDot); comRedDot.name = "comResDot"; comRedDot.SetPosition(parentCom.width - comRedDot.width, 0, 0); comRedDot.AddRelation(comRedDot, RelationType.TopExt_Top); comRedDot.AddRelation(comRedDot, RelationType.RightExt_Right); } else { if (parentCom.GetChild("comResDot") != null) { comRedDot = parentCom.GetChild("comResDot").asCom; comRedDotPool.Add(comRedDot); parentCom.RemoveChild(comRedDot); } } } } }