void ChangeSuit(bool increase) { SuitsDefinition suits = allSuits[currentIndex]; foreach (GameObject go in suits.suitParts) { go.SetActive(false); } if (suits.haveHelmet) { helmetToggle.interactable = false; helmetToggle.onValueChanged.RemoveAllListeners(); } currentIndex += increase ? 1 : -1; if (currentIndex > allSuits.Count - 1) { currentIndex = 0; } else if (currentIndex < 0) { currentIndex = allSuits.Count - 1; } suits = allSuits[currentIndex]; foreach (GameObject go in suits.suitParts) { go.SetActive(true); } if (suits.haveHelmet) { helmetToggle.interactable = true; helmetToggle.isOn = suits.haveHelmet; helmetToggle.onValueChanged.AddListener((val) => { HelmetChange(val, suits); }); } if (currentIndex == 0) { SuitEnable(true, true); } else { SuitEnable(suits.haveHands, false); } suitText.text = allSuits[currentIndex].suitName; }
void HelmetChange(bool val, SuitsDefinition s) { RemoveHeadAccessories(val, s.helmetAndAccessories); foreach (BodyParts b in allBodyParts) { if (b.bodyType == BodyType.Hair) { b.bodyParts[b.currentIndex].SetActive(false); b.nextBodyPart.interactable = !val; b.previosBodyPart.interactable = !val; b.currentIndex = s.defaultHairIndex; b.bodyNameDisplay.text = b.bodyParts[b.currentIndex].gameObject.name; b.bodyParts[b.currentIndex].SetActive(true); } } }