Unity 3D interface says my button has a rectTransform C# script says otherwise
I'm trying to position a button through a script and i'm hitting a dead end. The Unity Interface very clearly shows the button having a rectTransform , but if I try to access that in C# it throws an error. I can use the script to access the transform.position, but that doesn't actually change anything when I try it, and again, unity's interface doesn't show a position on the gameobject.
I have managed to move the text on the button via rectTransform, but not the button itself. Here is some example snippets.
public myscriptname MenuCanvas;
//this links to my prefab canvas that I create when needed
MenuCanvas.text0.rectTransform.sizeDelta = new Vector2(400f, 40f);
MenuCanvas.text0.rectTransform.localPosition = new Vector2(-175f, 200f);
//both of these work, they move a spesific text and resize it
MenuCanvas.button0.transform.position = new Vector3(-150f, 150f);
MenuCanvas.button0.transform.position = new Vector2(-150f, 150f);
MenuCanvas.button0.rectTransform.localPosition = new Vector3(-150f, 150f);
MenuCanvas.button0.rectTransform.localPosition = new Vector2(-150f, 150f);
none of these work. I cannot move the button , I tried both vector 2's and 3's in case maybe I missed something there. Thanks for any help you might have!
((Edited for Formating))
Your answer
Follow this Question
Related Questions
Can't find StartHost() function for a button 1 Answer
Canvas button not registering clicks 2 Answers
How can I change the UI button color when clicked 1 Answer
Button becomes unclickable if it is in the panel 0 Answers
Moved GameObject under Canvas (Parent), transform.position vector coordinates mismatch 0 Answers