2D Toolkit Forum

2D Toolkit => Support => Topic started by: Agosh on January 22, 2014, 07:11:15 am

Title: Problem with tk2dUIScrollableArea and tk2dTextMesh!!
Post by: Agosh 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?!
Title: Re: Problem with tk2dUIScrollableArea and tk2dTextMesh!!
Post by: unikronsoftware 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;
Title: Re: Problem with tk2dUIScrollableArea and tk2dTextMesh!!
Post by: Agosh on January 22, 2014, 10:26:57 am
How do I know - padding from tk2dTextMesh?
Title: Re: Problem with tk2dUIScrollableArea and tk2dTextMesh!!
Post by: unikronsoftware 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.
Title: Re: Problem with tk2dUIScrollableArea and tk2dTextMesh!!
Post by: Agosh 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???????
Title: Re: Problem with tk2dUIScrollableArea and tk2dTextMesh!!
Post by: unikronsoftware 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.
Title: Re: Problem with tk2dUIScrollableArea and tk2dTextMesh!!
Post by: Agosh 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
Title: Re: Problem with tk2dUIScrollableArea and tk2dTextMesh!!
Post by: unikronsoftware 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
Title: Re: Problem with tk2dUIScrollableArea and tk2dTextMesh!!
Post by: Agosh on January 22, 2014, 12:06:13 pm
Thank you very much! It helped!  :)