Information About Using the OnMouseDown Method

Asked 2 years ago, Updated 2 years ago, 256 views

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

2022-09-30 22:00

1 Answers

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".


2022-09-30 22:00

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.