- Home /
 
Why i can't see methods inside a script that directly dragged to the Onclick area inside the button and see them dragging canvas with that script inside it?,
Hello guys, I'm pretty new with Unity and I wonder why i can't see the methods inside the script by dragging dragging script to OnClick and i can see that methods by adding that script to canvas that the button resides and dragging canvas to OnClick area see all the methods inside the script.,
Answer by xxmariofer · Jan 31, 2019 at 10:22 PM
hello, you need to make it public, and if it is not marked public or private it will be marked private by default.
They are public but i can't see them if i directly drag from the script to Onclick area. I can see the script and it's methods if i put add script to canvas as a component and drag the canvas to the Onclick area.
oh i think i understand you now, for calling a method of a class, you $$anonymous$$UST have a reference to a object, it is the same like in runtime in script, for calling a method for setting the postion of a player for example you need a reference to that player, since your class player can be in multiple gameobjects, imagine if you were assigning directly script to the button from the assets, whichi player would be the one translating? you need a reference to a object for accessing the non static methods.
Your answer