- Home /
Question by
Pawandeep Singh · Jan 22, 2015 at 04:15 PM ·
positionresolutionui imageunity 4.6programmatically
Position UI Image/Text programmatically in Unity 4.6
I created UI Text programmatically in the c# script.
Text homeText;
gameObject.AddComponent<Text> ();
homeText.text = "hello world";
But I don't know how to position it programmatically for difference screen resolutions . Using Unity 4.6.
Thank You
Comment
Answer by Ryujose · Jan 22, 2015 at 06:45 PM
Use line using UnityEngine.UI to interact with UI canvas.
Change Text homeText; to Public Text homeText;
Then add a canvas Text on hierarchy.
Drop this canvas Text added on hierarchy on the public Text homeText; .
Configure it like you want on inspector.
Note: If you configure homeText.text = "hello world"; from script, always you'll get this value.
Hope it will helpfull for you.
Regards.
Your answer