Hi all,
I can't find reference to GameObject[] in any manual, so I'm asking my most basic questions here. I've made a script for customising hats, and have made each hat a value of `var hats : GameObject[]` . Here's the script:
var hats : GameObject[];
var activeHat : int;
function Update ()
{
if (PlayerPrefs.GetInt("ChosenHat") > /*I'm not sure here*/)
{
PlayerPrefs.SetInt("ChosenHat", 0);
}
hats[activeHat].SetActiveRecursively(true);
hats[!activeHat].SetActiveRecursively(false);
}
My first question is: How do I access the 'size' part of the hats variable (i.e the max number of hats) and the second arises from the `hats[!active].SetActiveRecursively(false);` line. This works, however only when hats[activeHat] is 0 or 1. My 0 hat is just an empty game object, so the character has no hat, and the 1 hat is a cap. Whenever I flick the activehat variable between 0 and 1, it deactivates the cap and (I assume) activates the empty game object, and vice versa. However, when I make activeHat 2 or more, it activates the hats fine, but just doesn't deactivate any. So my second question is How do you get that working?
Thanks a bunch!