- Home /
GUI buttons referencing wrong object.
Hey All,
I have a script attached to an object, imagine there is a variable called weaponLevel and I want a GUIbutton to increase that weaponLevel by 1 when it's clicked. This is the code I have chosen.
if(GUI.Button(Rect(450,217,28,28),""))//Weapon LevelUp
{
weaponLevel += 1;
}
You'd think that would work wouldn't you, but its only increasing a variable called weaponLevel in another object even though the variable in the same script that the OnGUI function is..... Why is it doing this?
If I was you I would change the name of the variable :) To be more serious is this variable private? How many object are there? Are they nested? In other words you should give us the possibility to replicate you scene...
Your answer
Follow this Question
Related Questions
On Clicked, On Released GUI Button ? 2 Answers
How to WaitforSeconds a GuiButton ? 0 Answers
Check if GUI is Pressed 1 Answer
gui.button down 2 Answers
Infinite GUI Button positions. 3 Answers