Created
March 10, 2017 14:34
-
-
Save kamend/cd540f41659a8451143021e79b8330e9 to your computer and use it in GitHub Desktop.
Position a UI element based on a World Position
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Vector2 screenPos = camera.WorldToViewportPoint( worldPosition ); | |
screenPos.x *= guiCanvas.rect.width; | |
screenPos.y *= guiCanvas.rect.height; | |
// the element should be anchored bottom/left | |
uiElement.anchoredPosition = screenPos; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment