/// <summary> /// Initialize BodyTypeGroup and populate the items. /// </summary> public void Initialize() { this.CreatorUI = this.transform.GetComponentInParent <UICreator>(); if (this.CreatorUI == null) { return; } Transform itemparent = getItemParent(); Dictionary <string, List <BodyType> > bodytypes = getAvailableBodyTypes(); clearItems(); foreach (string packagename in bodytypes.Keys) { PackageItem packitem = Instantiate <PackageItem>(tPackage, itemparent); packitem.Initialize(packagename); foreach (BodyType bodytype in bodytypes[packagename]) { BodyTypeItem bodyitem = Instantiate <BodyTypeItem>(tBodyTypeItem, itemparent); bodyitem.Initialize(bodytype); if (bodytype == CreatorUI.character.bodyType) { selectedItem = bodyitem; if (this.gameObject.activeInHierarchy) { StopCoroutine("ie_initselected"); StartCoroutine("ie_initselected", selectedItem); } } } } _bodycolors = getBodyColors(); }
private void spawnItem(BodyType bodyType, Part bodySkin, Transform itemParent) { Part assignedpart = CreatorUI.character.GetAssignedPart(SlotCategory.BodySkin); if (bodySkin == null) //spawn NULL { BodyTypeItem partitem = Instantiate <BodyTypeItem>(tBodyTypeItem, itemParent); partitem.Initialize(bodyType, null); if (CreatorUI.character.bodyType == bodyType && assignedpart == null) { selectedItem = partitem; if (this.gameObject.activeInHierarchy) { StopCoroutine("ie_initselected"); StartCoroutine("ie_initselected", selectedItem); } } } else { BodyTypeItem partitem = Instantiate <BodyTypeItem>(tBodyTypeItem, itemParent); partitem.Initialize(bodyType, bodySkin); if (CreatorUI.character.bodyType == bodyType && assignedpart == bodySkin) { selectedItem = partitem; if (this.gameObject.activeInHierarchy) { StopCoroutine("ie_initselected"); StartCoroutine("ie_initselected", selectedItem); } } } }