private void Start() { canvas = GetComponent <Canvas>(); bubble = transform.Find("Bubble").gameObject.AddComponent <SingleBubble>(); bubble.Init(); bubble.gameObject.SetActive(false); bubbles = new List <SingleBubble>(); bubblePools = new List <SingleBubble>(); }
public void Recycle(SingleBubble bubble) { if (bubbles.Contains(bubble)) { bubbles.Remove(bubble); } if (!bubblePools.Contains(bubble)) { bubblePools.Add(bubble); } }
public void ShowBubble(DialogueUIData data) { SingleBubble bubble; if (bubblePools.Count <= 0) { bubble = Clone(); } else { bubble = bubblePools[0]; bubblePools.RemoveAt(0); } bubbles.Add(bubble); bubble.Show(data); }