E
E
ebanytiu_lis2020-01-29 15:10:25
Unity
ebanytiu_lis, 2020-01-29 15:10:25

How to move cursor in canvas over 3d objects?

Let's say there is a scene: a camera, a light, a canvas with a sprite, three cubes.
By pressing the arrows (left, right) you need to move the sprite in the canvas so that it is on the screen on top of the cube object.
How I saw it and how I tried to implement it:
Through camera.WorldToScreenPoint we get the coordinates of the cube on the screen, we change the coordinates of the sprite to the received coordinates.
Thank you in advance!

Answer the question

In order to leave comments, you need to log in

1 answer(s)
G
GavriKos, 2020-01-29
@GavriKos

change the sprite coordinates to the received coordinates.

show the code for this part.
+hierarchy screen, canvas parameters
All of a sudden the ScreenPoint might not match what the UI expects - they might have different origins, different anchor points, etc.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question