Hello
I’m making a script where if a sprite is clicked, its color is changed to red. However, I do not know how to call the game object that is using the script inside this script. How do I do that?
Not sure exactly what you are asking, but to access the game object running a script, simply type gameObject.
.
I would suggest if you don’t know these basics you would be better off spending 30 mins following along to a basic scripting tutorial to get the foundational knowledge than asking specific questions here.
What do you mean call a GameObject? A GameObject is a class. You dont call classes.
Do you want to call a method or your MonoBehaviour/ Component on that GameObject?
If so the click is detected on the OnMouseDown event. How do you know which game object it is being called on? Which ever instance of that GameObject has had its OnMouseDown method invoked.
I would probably mirror MUG806s advice, spend some time learning about C#, programming in general and Unity. I suggest that you are able to at the very least understand how things work at a high level and have at least an understanding of how to read the documentation (both C#/.NETs and Unitys) before attempting to use it.