- Home /
Answer by DiegoSLTS · Feb 25, 2015 at 12:41 AM
I don't understand what you mean by "rect", but since you used the "ui" tag I guess you're talking about unity's new UI, you added an Image game object on a canvas and set a sprite you imported as the "Source Image" on the Image component of that Image game object. That's what you did?
If that's the case, when you rotate that game object it rotates from the center, not from the pivot.
Well, from all that guessing, if you want to set the pivot you have a "Pivot" property in the Rect Transform of the Image game object. Pivots go from 0 to 1, 0 means left (for x) and bottom (for y), 1 means right or top.
All the other things I could imagine from your message use the pivot selected on the Sprite Editor.
Added a Sprite directly as a child of the Canvas and it rotates from the pivot.
Added a Sprite on the scene (outside the canvas) and it rotates from the pivot.
Yes, the first thing. How can I rotate object around a point then?
I just said that:
Well, from all that guessing, if you want to set the pivot you have a "Pivot" property in the Rect Transform of the Image game object. Pivots go from 0 to 1, 0 means left (for x) and bottom (for y), 1 means right or top.
Any pivot that you set between 0 and 1 will be inside the component, but you can use any other value and the object will rotate around that point.
Note that pivot is used for local rotation, not for global rotation. For global rotation you can try with: http://docs.unity3d.com/ScriptReference/Transform.RotateAround.html
Answer by JohannChristoph · Apr 01, 2016 at 04:02 AM
I couldn't move around the Pivot of the Rect Transform because it was kind of deactivated (semi transparent). The Pivot Setting in the main Unity Editor UI (in the upper left corner, right to the editor tool bar) has to be set to Pivot (not Center). Then it works.
Your answer
Follow this Question
Related Questions
How to change the Top and Bottom (rect.yMin and yMax) properties of a rectTransform, in a script? 2 Answers
Change size of the new UI rect transform using scripts 0 Answers
UI How to configure Left And Right. 1 Answer
Convert Input.mousePosition to RectTransform pivot position 2 Answers
Way to create/draw a resizable rect/Rect tool through code? 1 Answer