Skip to main content


Showing posts from April, 2016

How to move unity UI using mouse

Make UI Image Follow Mouse Position
4.6 UI Image follow mouse position
move UI object to click position

Hello guys,

As we all know this is the most basic thing we do in Unity, That is 'dragging stuffs', and there is one straight forward solution to it, which works perfectly. But in some cases it will not, that is the reason you see a lot of forum posts on this topic, and we don't understand why its not working for us but the same thing is working for others.

this is the code for dragging UI with our mouse.
rect is a type off  RectTransform   so don't get confused.

Simple right ?

Than why sometime it doesn't work ?


I got stuck in a similar problem few days back, and i found out that there are certain reason's, that above code will not work.

check out this image:

Here you can see that my pointer and my image are at same position, this is because i have set the Image anchors to bottom left position w…