public void removeNode(GameObject node) { if (nodeList.Count == 0) { return; } LListNode del = null; foreach (LListNode elem in nodeList) { if (elem.obj == node) { del = elem; nodeList.Remove(elem); break; } } if (limitNum > 0) { pushFreePool(del); } else { Object.Destroy(node); } }
private void pushFreePool(LListNode node) { if (!freeDic.ContainsKey(node.tpl_id)) { freeDic.Add(node.tpl_id, new List <LListNode>()); } freeDic[node.tpl_id].Add(node); node.obj.SetActive(false); }
private LListNode popFreePool(int id) { if (!freeDic.ContainsKey(id)) { freeDic.Add(id, new List <LListNode>()); } LListNode node = null; if (freeDic[id].Count > 0) { node = freeDic[id][0]; freeDic[id].RemoveAt(0); node.obj.SetActive(true); } return(node); }
public void removeNodeAtIndex(int idx) { if (nodeList.Count == 0) { return; } if (limitNum > 0) { LListNode node = nodeList[idx]; pushFreePool(node); } else { Object.Destroy(nodeList[idx].obj); } nodeList.RemoveAt(idx); }
public GameObject dequeueItem(int id) { GameObject ret = null; if (limitNum > 0) { LListNode node = popFreePool(id); if (node != null) { ret = node.obj; } } if (ret == null) { ret = Instantiate(transform.Find("container/cell_tpl" + id).gameObject); ret.SetActive(true); } return(ret); }