Hello Guest

Author Topic: Updating tk2dUILayout collider at runtime  (Read 3253 times)

LaserDinosaur

  • 2D Toolkit
  • Newbie
  • *
  • Posts: 38
    • View Profile
Updating tk2dUILayout collider at runtime
« on: August 16, 2014, 01:10:42 am »
Hi

I have a popup window that has various amounts of content. The window has a tk2dUILayout component which contains a button called "Fit Layout To Geometry".

Clicking this works fine when in edit mode, but I also want to fire that same event at runtime after I've added content to my window.

Am I missing a very obvious method somewhere or is resizing the colliders at runtime more tricky than that?

Cheers!

unikronsoftware

  • Administrator
  • Hero Member
  • *****
  • Posts: 9709
    • View Profile
Re: Updating tk2dUILayout collider at runtime
« Reply #1 on: August 16, 2014, 12:06:03 pm »
Fit layout is a really expensive operation, which is why it isn't available at runtime. We've never had the need for this at runtime, so its never been a priority.

Your best bet is to simply replicate the code that runs in the button press in your runtime class. If you can evaluate the size of your controls by other means, eg. if you know that only the base objects need to be considered - all this function does is it finds the largest bounding box that covers all the controls and resizes the layout to fit that.