private void RemoveItem(TItem item) { item.Index = -1; CachedClone.RemoveClone(item.gameObject); items.Remove(item); OnItemRemove(item); }
private void AddComponent() { TComponent component = CachedClone.Clone(templateViewItem.gameObject).GetComponent <TComponent>(); component.Index = -1; component.transform.SetAsLastSibling(); components.Add(component); }
public static void RemoveClone(GameObject go, bool bDel = false) { CachedClone comp = go.GetComponent <CachedClone>(); if (null != comp && null != comp.cloneFrom) { comp.cloneFrom.Remove(go, bDel); } }
private TItem AddItem() { TItem item = CachedClone.Clone(template.gameObject).GetComponent <TItem>(); item.Index = items.Count; item.transform.SetAsLastSibling(); items.Add(item); OnItemAdd(item); return(item); }
public void ReleaseItem() { if (null != itemGo) { if (isFollowing) { isFollowing = false; Follow3DBy2D.StopFollower(itemGo); } CachedClone.RemoveClone(itemGo, false); itemGo = null; item = null; } }
public static void Reserve(GameObject go, int reserveSize) { CachedClone comp = go.GetComponent <CachedClone>(); if (null == comp) //如果没有则作为源 { comp = go.AddComponent <CachedClone>(); } if (null != comp.cloneFrom) { comp = comp.cloneFrom; } comp.Reserve(reserveSize); }
public static GameObject Clone(GameObject go) { CachedClone comp = go.GetComponent <CachedClone>(); if (null == comp) //如果没有则作为源 { comp = go.AddComponent <CachedClone>(); } if (null == comp.cloneFrom) { return(comp.CloneSelf()); } else { return(comp.cloneFrom.CloneSelf()); } }
private GameObject CreateClone(bool bActive) { GameObject clone = GameObject.Instantiate(CachedGo) as GameObject; clone.name = string.Format("{0}_{1:D3}", clone.name, ++itemIdx); Transform cloneTrans = clone.transform; cloneTrans.SetParent(CachedTrans.parent, false); //cloneTrans.parent = CachedTrans.parent; cloneTrans.localPosition = CachedTrans.localPosition; cloneTrans.localScale = CachedTrans.localScale; cloneTrans.localRotation = CachedTrans.localRotation; CachedClone comp = clone.GetComponent <CachedClone>(); if (null == comp) { comp = clone.AddComponent <CachedClone>(); } comp.cloneFrom = this; clone.SetActive(bActive); return(clone); }
private void RemoveComponent(TComponent component) { component.Index = -1; CachedClone.RemoveClone(component.gameObject); }