- Home /
One script for many Game Objects with different values
My game has 1000+ small cubes. Each has its own status in the form of a string. Since its so many Game Objects, I want to create one script and use it for all. Inside this script, there is an OnMouseOver method that overrides the value of a GUI. There is only one GUI (in order not have 1000 GUIs).
public string status; private string localstatus;
OnMouseOver() { status = localstatus; }
On MouseExit() { status = ""; }
The problem is that the script only works for one Cube and not for the rest. That is, only for the first cube that I placed it into. Why is this? Can't I have the same script in different gameobjects with different values?
Your answer
Follow this Question
Related Questions
How can I add the OnTriggerEnter function to all game objects that I instantiate? 1 Answer
Why are these object passing through each other? 1 Answer
Calculating Scrolling GameObject x position scrolling pass another GameObject x postion (2D Game) 1 Answer
Update list on mouse click 1 Answer
How do I play gameobjects in my scene from one script / Script is not working 0 Answers