Hello Guest

Author Topic: Resize tk2dUIScrollableArea on real time  (Read 4332 times)

prodyminds

  • 2D Toolkit
  • Newbie
  • *
  • Posts: 9
    • View Profile
Resize tk2dUIScrollableArea on real time
« on: September 05, 2013, 10:47:49 pm »
Hi, i'm making a folders system (a button that has content down) and using iTween expand and contract the content. All of this things are inside a tk2dUIScrollableArea, but i need to fix on realtime the size of the content (ContentLength).

To make the extension I use tk2dUIItemBoundsHelper on editor classes to get the size, but when i want to do it on real time Unity debug me this:

Quote
Assets/Scripts/Manager/MenuManager.cs(24,33): error CS0103: The name `tk2dUIItemBoundsHelper' does not exist in the current context

gary-unikronsoftware

  • 2D Toolkit
  • Jr. Member
  • *
  • Posts: 74
    • View Profile
Re: Resize tk2dUIScrollableArea on real time
« Reply #1 on: September 06, 2013, 10:19:28 am »
Hi,

First off I'll start by saying I haven't tried this so don't know how successful it will be...

The problem is the tk2dUIItemBoundsHelper code is part of the Editor and as such can't be called at runtime.  However, the class is a static class so doesn't depend on an instance of it being created, so you could try copying the code into a non-Editor class (changing the name of the class obviously) and tweak the code where necessary need to get the same functionality.

Unikron may be around shortly with a better idea, but you can try that in the meantime :-)


unikronsoftware

  • Administrator
  • Hero Member
  • *****
  • Posts: 9709
    • View Profile
Re: Resize tk2dUIScrollableArea on real time
« Reply #2 on: September 06, 2013, 01:30:09 pm »
Hi there,

There is a function on the tk2dScrollableArea.MeasurecontentLength which measures the content length outside the editor. However, if you look at 2D Toolkit 2.2 beta - it has support for layouts, which pretty much automates all of this. You can simply resize the scrollablearea and let the layout take care of everything for you.

prodyminds

  • 2D Toolkit
  • Newbie
  • *
  • Posts: 9
    • View Profile
Re: Resize tk2dUIScrollableArea on real time
« Reply #3 on: September 06, 2013, 01:54:38 pm »
After post i realize that i could take out the tk2dUIItemBoundsHelper class from editor. But the tk2dScrollableArea.MeasurecontentLength function was a better solution.

Thank both of you.