Skip to content

Instantly share code, notes, and snippets.

@kamend
Created March 10, 2017 14:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kamend/cd540f41659a8451143021e79b8330e9 to your computer and use it in GitHub Desktop.
Save kamend/cd540f41659a8451143021e79b8330e9 to your computer and use it in GitHub Desktop.
Position a UI element based on a World Position
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