- Home /
Question by
CunningGrayFox · Dec 05, 2014 at 01:53 PM ·
uipositionrelative position
Positioning New UI Elements In 4.6 At Runtime
I'm having trouble positioning elements using the new UI system via script at runtime.
This is an example of what I had under the old system.
gameObject.transform.position = Camera.main.ScreenToWorldPoint(new Vector3(pointX, pointY, pointZ));
With 4.6 this positions everything in the lower left corner no matter what values I pass into it. I guess the heart of my question is what kind of space is the canvas and what method exists to translate screen space to that kind of space.
Comment
Answer by HarshadK · Dec 05, 2014 at 01:03 PM
You need to go through these two tutorials:
They have how elements are positioned which you can use to position them at runtime.