public void Initialize() { this.emoteUI = this.transform.GetComponentInParent <UIEmote>(); if (this.emoteUI == null) { return; } emotionType = emoteUI.activeEmotion; emoteIndex = emoteUI.character.emotes.getIndex(emotionType); Transform itemparent = this.transform.Find("List/Content"); Dictionary <string, List <Part> > parts = getAvailableParts(); Part assignedpart = emoteIndex.getPart(slotCategory); clearItems(); selectionObj.gameObject.SetActive(false); //..add null EmotePartItem partitem = Instantiate <EmotePartItem>(emotePartItem, itemparent); partitem.Initialize(null); if (assignedpart == null) { selectedItem = partitem; if (this.gameObject.activeInHierarchy) { StopCoroutine("ie_initselected"); StartCoroutine("ie_initselected", selectedItem); } } //add null.. foreach (string packagename in parts.Keys) { PackageItem packitem = Instantiate <PackageItem>(packageItem, itemparent); packitem.Initialize(packagename); foreach (Part part in parts[packagename]) { partitem = Instantiate <EmotePartItem>(emotePartItem, itemparent); partitem.Initialize(part); if (part == assignedpart) { selectedItem = partitem; if (this.gameObject.activeInHierarchy) { StopCoroutine("ie_initselected"); StartCoroutine("ie_initselected", selectedItem); } } } } }
IEnumerator ie_initselected(EmotePartItem item) { yield return(null); SelectItem(item); }
public void SelectItem(EmotePartItem item) { selectedItem = item; selectionObj.gameObject.SetActive(true); selectionObj.position = item.transform.position; }