void Refresh() { for (int i = 0; i < allitems.Count; i++) { if (allitems[i] != null) { allitems[i].gameObject.SetActive(false); } } curList.Sort(GuildItemCompare.Instance); for (int i = 0; i < curList.Count; i++) { if (!allitems.ContainsKey(i)) { GuildItem guildItem = GuildItem.CreateNew(parent.transform); guildItem.SetData(curList[i] as GuildData); allitems[i] = guildItem; } else { allitems[i].SetData(curList[i] as GuildData); } //allitems[i].transform.localPosition = new Vector3(positionInfo.x,positionInfo.y+positionInfo.w*i,-1); allitems[i].gameObject.SetActive(true); } parent.repositionNow = true; if (scrollView != null) { scrollView.SetDragAmount(0, 0, false); } }
public static GuildItem CreateNew(Transform _parent) { GameObject go = null; UnityEngine.Object prefab = exResources.GetResource(ResourceType.GUI, "Guild/GuildListItem"); go = Instantiate(prefab) as GameObject; prefab = null; go.transform.parent = _parent; go.SetActive(true); go.transform.localPosition = Vector3.zero; go.transform.localScale = Vector3.one; GuildItem guildItem = go.GetComponent <GuildItem>(); if (guildItem == null) { guildItem = go.AddComponent <GuildItem>(); } return(guildItem); }