Hello Guest

Author Topic: Problem with tk2dUIScrollableArea and tk2dTextMesh!!  (Read 6151 times)

Agosh

  • 2D Toolkit
  • Newbie
  • *
  • Posts: 5
    • View Profile
Problem with tk2dUIScrollableArea and tk2dTextMesh!!
« on: January 22, 2014, 07:11:15 am »
Unity 4.3.3 f1
2D Toolkit 2.3.3

I have a tk2dUIScrollableArea object on the Scene. In its Content property , the object must be a tk2dTextMesh object.

In the script, the text property of tk2dTextMesh should be changed.

All my attempts do not alter the ContentLength property of tk2dUIScrollableArea.

(MeasureContentLength ()
-no effect.

textGO.transform.parent = null;
text: text + = "Blablabla.";
tehtGO. parent transform. = ScrollableMenu.contentContainer.transform;
-no effect.
And so on.)

I have tried everything and can't understand why it is not happening. And very pleased this extremely intuitivony things!  >:(

The main question is how to do it?!
« Last Edit: January 22, 2014, 07:27:06 am by Agosh »

unikronsoftware

  • Administrator
  • Hero Member
  • *****
  • Posts: 9709
    • View Profile
Re: Problem with tk2dUIScrollableArea and tk2dTextMesh!!
« Reply #1 on: January 22, 2014, 10:11:10 am »
MeasureContentLength gives you the content length, it doesn't set it.
You just need to set it after that, and add whatever padding you need if necessary.


scrollableArea.ContentLength = scrollableArea.MeasureContentLength() + padding;

Agosh

  • 2D Toolkit
  • Newbie
  • *
  • Posts: 5
    • View Profile
Re: Problem with tk2dUIScrollableArea and tk2dTextMesh!!
« Reply #2 on: January 22, 2014, 10:26:57 am »
How do I know - padding from tk2dTextMesh?

unikronsoftware

  • Administrator
  • Hero Member
  • *****
  • Posts: 9709
    • View Profile
Re: Problem with tk2dUIScrollableArea and tk2dTextMesh!!
« Reply #3 on: January 22, 2014, 10:31:34 am »
padding is your own choice - how much of extra space do you want to give it. You don't have to put it in if you don't want to.

Agosh

  • 2D Toolkit
  • Newbie
  • *
  • Posts: 5
    • View Profile
Re: Problem with tk2dUIScrollableArea and tk2dTextMesh!!
« Reply #4 on: January 22, 2014, 10:34:33 am »
I want to change the padding depending on the properties of the text tk2dTextMesh.
how do I do???????

unikronsoftware

  • Administrator
  • Hero Member
  • *****
  • Posts: 9709
    • View Profile
Re: Problem with tk2dUIScrollableArea and tk2dTextMesh!!
« Reply #5 on: January 22, 2014, 10:37:29 am »
Why do you want to do that? The content size should already be set to the size of the text mesh. Has the text changed on the mesh yet? If it hasn't, you will probably have to call Commit() to force it to change immediately.

Agosh

  • 2D Toolkit
  • Newbie
  • *
  • Posts: 5
    • View Profile
Re: Problem with tk2dUIScrollableArea and tk2dTextMesh!!
« Reply #6 on: January 22, 2014, 10:39:57 am »
Because I change the text from the script
And this text is located in content of tk2dUIScrollableArea

After that ContentLength not change and scroll work not correctly
« Last Edit: January 22, 2014, 10:47:58 am by Agosh »

unikronsoftware

  • Administrator
  • Hero Member
  • *****
  • Posts: 9709
    • View Profile
Re: Problem with tk2dUIScrollableArea and tk2dTextMesh!!
« Reply #7 on: January 22, 2014, 11:46:13 am »
1. Change text from script.
2. Call textMesh.Commit() - this will update the mesh immediately instead of at the end of the frame
3. scrollableArea.ContentLength = scrollableArea.MeasureContentLength()

That should work as expected

Agosh

  • 2D Toolkit
  • Newbie
  • *
  • Posts: 5
    • View Profile
Re: Problem with tk2dUIScrollableArea and tk2dTextMesh!!
« Reply #8 on: January 22, 2014, 12:06:13 pm »
Thank you very much! It helped!  :)