I have a Random.ColorHSV
that randomizes, well, a color. The problem is , I have about 10 objects with this script running the Random.ColorHSV
, so it randomizes 10 times. How can I have it randomized only once?
Thanks in advance!
I have a Random.ColorHSV
that randomizes, well, a color. The problem is , I have about 10 objects with this script running the Random.ColorHSV
, so it randomizes 10 times. How can I have it randomized only once?
Thanks in advance!
If you mean you want to random the color once and share it within the 10 objects, you can have a super-class do the randoming and store it there for the 10 objects to just access it as a property.
EDIT: You can do it a couple of ways, an easy one is to make a new script and attach it to a gameobject in your scene that could be acting as a game manager (having functions to manage the game’s state or so) and make it randomize the color at the start of the game.
public Class GameManager : Monobehaviour {
public static Color randomizedColor;
void Start(){ //you can also use Awake here if the objects take their color in their Start method
randomizedColor = Random.ColorHSV(0f, 1f, 1f, 1f, 0.5f, 1f);
}
}
And then in your objects you can call:
currentObsColor = GameManager.randomizedColor;