- Home /
Question by
jellyberg · Jun 25, 2015 at 09:11 PM ·
uiconvertworldtoscreenpoint
Convert UI element screen position to world position
I want to instantiate a GameObject at the screen position of a UI button, which is on a Screen Space - Overlay canvas. My current code is:
Vector3 buttonWorldPosition = localCamera.ScreenToWorldPoint(inventoryButton.transform.position);
However this does not seem to work as desired because the UI button's transform.position is (-30, -30, 0), despite it being positioned in the top right of the screen.
Any ideas?
Comment
Your answer
![](https://koobas.hobune.stream/wayback/20220613201412im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
How can I accurately convert a Game Object's position to a sub Canvas/Rect screen position? 0 Answers
Correct use of transform.position of UI element into game screen 1 Answer
WorldToScreenPoint UI element showing up twice 1 Answer
Converting UGUI text to 3D text. 0 Answers
C# Cannot implicitly convert type UnityEngine.UI.Selectable to UnityEngine.UI.Selectable 2 Answers