0

How do I resize the height of the gameobject SQLDataTable so that it shrinks down in height but keeps its fixed position on the canvas? As you can see, the text above it (helptext gameobject, which has content size fitter, preferred fit on vertical size) overflows into the table.

Now I know how to move the table down with the above text, I would make the table a child, but I don't want to do that. I want to just reduce the height of the table in relation to the above text, also ignore the errors.

enter image description here

2 Answers 2

1

If you have a UI canvas element that you want to change height or width on, you'll want to do something like the following:

int height = 1000; // or whatever
gameObject.GetComponent<RectTransform>().SetSizeWithCurrentAnchors(RectTransform.Axis.Vertical, height);

(You'll need to change the Axis to RectTransform.Axis.Horizontal to change the width.)

This is quite an old post, but I did some googling for how to set the height of a UI element programmatically (and ended up here). I assume it's way to late to help the OP, but hopefully someone else will find it useful.

Sign up to request clarification or add additional context in comments.

Comments

0

I recomend you to take a look to this page; it comes with a useful scripts to use the new UI; specifically the uGUITools. It saves a lot of time.

Now, what I do is an array of canvas that looks like the imagen aboveenter image description here

Please ignore the buttons each in front other, I suear that works on mobile devices, so you need the GridLayoutGroup or a VerticalLayoutGroup that let you achieve what yuo want.

By the way, I'm downloading information from a DB and put those info in a new element inside a Grid so I can scroll horizontally between elements making a matrix[9xn].

Ps. Sorry for my bad english.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.