#buttons
1 messages · Page 1 of 1 (latest)
Show me the inspector for the button again.
yes
ok
And GetComponent<Button> got itself
so what should i change?
Rename your class to something else.
here's how you want to do that
- In Unity, rename the script asset in the Project window to
PlayAgainButton. - In your code editor, rename the class from
ButtontoPlayAgainButton
If you just rename the file outside of Unity, it will think you deleted the old script and made a new script.
how do i do the second point?
public class Button : MonoBehaviour
replace that with
public class PlayAgainButton : MonoBehaviour
Just make it so the name isn't Button.
You have the Button component enabled.
The if statement will never succeed.
because the second conditions is restartd.enabled == false
no problem!
the same-name problem can be very tricky
you had two different problems like that, actually
How do you learn all that stuff
- the wrong
usingstatement gave you the wrongImageclass - your
Buttonhid unity'sUnityEngine.UI.Button
Just time and practice, really!
Ok
but when i google such problems i cant find anything
its working but i got a new problem
Something on line 21 is null
Clicking on the error in the console -- just once -- will highlight the object in the hierarchy
(While the game is running, at least)
Sounds like you have an extra copy of the component on it
you probably didn't want that
well, you have no audio source assigned
@granite sable Hello! I want to make a note for you, whenever you deal with Null References try to do something like
{
Do that thing you want!
}
Else
{
Debug.Log("Value is null it has no reference!")
}```
Also, check your components in the inspector like @forest belfry told you maybe you have not assigned an ``Audio Clip`` or ``Animation`` or whatever it is maybe a ``text`` so that's why it says that it is null you have no reference, so if you have no reference then how it's going to know what you want to do. That makes sense! Hope I helped you!
Thank you
@granite sable Have you dealt with that issue? Can I leave this thread if you done with that and need no help anymore?