/// <summary> /// 由cell派发消息 /// </summary> /// <param name="buttonId"></param> /// <param name="cell"></param> public void NotifyEvent(string eventName, UICell cell, bool flag = true) { if (eventName.Equals(UICell.ClickCellEvent)) { _curSelectIndex = cell.index; } gameObject.BroadcastMessage("OnBroadcastSelectIndex", _curSelectIndex, SendMessageOptions.DontRequireReceiver); onCellEvent.Invoke(eventName, cell, flag); }
public void RemoveCell(Transform item) { if (item == null) { return; } UICell cell = item.GetComponent <UICell>(); RemoveCell(cell); }
/// <summary> /// 加入一个item, 要手动调用ResetPosition 排序 /// </summary> public UICell AddItem(object context) { if (Template == null) { Debug.LogError("list template is null"); return(null); } if (_curPool == null) { initPool(); } UICell cel = createItem(context, ChildCount + 1); if (CellMaxCount > 0 && ChildCount > CellMaxCount) { RemoveFirst(); } _cells.Add(cel); return(cel); }
protected virtual UICell createItem(object context, int i) { Transform tf = spawn(); if (tf == null) { return(null); } GameObject go = tf.gameObject; go.SetActive(true); tf.SetParent(content); tf.localPosition = Vector3.zero; tf.localScale = Vector3.one; UICell t = go.GetComponent <UICell>(); //go.name = i.ToString(); t.Init(this); t.SetData(i, context, i == _curSelectIndex); _cells.Add(t); return(t); }
public void RemoveCell(UICell cell) { _cells.Remove(cell); unSpawn(cell.transform); }