Question by
PatriotsUnity · Feb 22, 2016 at 09:58 AM ·
arraycharacterselection
Array of Texts that change dynamic on selected character
hii , im having logic problem to understand how i can do something in Unity C#
i have a screen where i can see my 6 Characters on screen , below each 1 of them i made a Button and Text that represent the PRICE (all of them cost the same , 150)
now when i load the scene i want to load a method "Load();" that will check
1) Which character is SELECTED > make his Text to SELECTED And Turn others to "Unselected" > But if the others didnt unlocked yet?
2) which Character is UNLOCKED > if some characters are unlocked > Make their Text to "Unlocked" But what if half of them not unlocked already? > Make their text to the PRICE (150)
3) Adding the Defualt aswell to all of that
i have try to make FOR loop but i cant understand it fully and i fail .
for (int i = 0; i < characters.Length; i++)
{
if (PlayerPrefs.HasKey(characters[i].characterPrefab.name + i + "s"))
{
characters[i].isSelected = Utilities.GetBool(characters[i].characterPrefab.name + i + "s");
}
if (PlayerPrefs.HasKey(characters[i].characterPrefab.name + i + "p"))
{
characters[i].purchased = Utilities.GetBool(characters[i].characterPrefab.name + i + "p");
}
}
Comment
Your answer
![](https://koobas.hobune.stream/wayback/20220612065138im_/https://answers.unity.com/themes/thub/images/avi.jpg)