- Home /
How to change the Top and Bottom (rect.yMin and yMax) properties of a rectTransform, in a script?
Hey guys. I made an image (with child images and buttons and what not) and made it a prefab. I am not trying to Instantiate it, however when I do, its transform info is all messed up. No problem, I can fix that manually in the code right after I instantiate it!
(NOTE: My image has the anchors at the corners of the image, NOT next to each other. That matters)
I've figured out that:
localPosition = how to change posZ
sizeDelta = how to change Left and Right
localScale = how to changescale
but HOW do you change Top and Bottom? I know how to READ them (rectTransform.rect.yMin and yMax), but how to I CHANGE them?
Answer by curiouspers · Jan 24, 2015 at 01:56 PM
I think that one should help.
take a look at anchoredPosition and anchoredPosition3D, use it like this:
text.rectTransform.anchoredPosition3D = new Vector3(my_new_x, my_new_y, my_new_z);
Answer by Mmmpies · Jan 17, 2015 at 09:34 AM
Not sure if this will help but it fixed an issue I had with a camera not pointing in the normal UI way, as in I have a menu that can show 3D items on Unity indy which means having a camera pointing down from the terrain. However it also deals with spells which are just prefab panels.
When I switched the new UI it was displaying them edge on! Anyway try this:
transfrom.localRotation = Quaternion.Euler(0.0f,0.0f,0.0f);
Your answer
Follow this Question
Related Questions
Horizontal Layout Group making a Scroll Rect's Content rect width to be negative 1 Answer
UI How to configure Left And Right. 1 Answer
Revers Object Transfrom using an array problem in UI !! 0 Answers
Change size of the new UI rect transform using scripts 0 Answers
SetAsLastSibling seems to sort alphabetically when used across different objects. 0 Answers