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

user3071284
  • 6,955
  • 6
  • 43
  • 57
Martin Dawson
  • 7,455
  • 6
  • 49
  • 92

2 Answers2

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.

livingtech
  • 3,570
  • 29
  • 42
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.