I'd like to create a script that displays prediction lines when I drag the mouse, but I'm currently using Ball as the object I want to display prediction lines and GameObject as the object I attached the script to.
Is there a way to use Ball in the OnMouseDown method?
Also, there are other code descriptions, so I don't want to change the object to which I want to attach the script from GameObject if possible.
If anyone knows, please let me know.
c# unity3d
The instructions for finding objects are as follows:
GameObject ball=GameObject.Find("Ball");
Note that it is not recommended to use this function every frame because this process is heavy.
There are several other ways to retrieve it, but I think you can get information by searching the web around "Find unity Object".
© 2025 OneMinuteCode. All rights reserved.