
Hello, I\'m using the new UI system from Unity 4.6 beta...
Tried diffe
You normally don't want to modify directly those values, even more if they come from a prefab you have already setup with the correct coords, if you just want to add it correctly under canvas (or other) but it "changes position" do this:
GameObject instance;
void Start () {
GameObject canvas = GameObject.Find ("Canvas");
if (canvas != null) {
GameObject go = Resources.Load("MyPrefab");
if(go != null){
instance = Instantiate(go);
instance.GetComponent().SetParent(canvas.GetComponent(), false);
}
}
}
Passing false on set parent will avoid the rect transform being changed in weird forms when instantiating the prefab.