2D Toolkit Forum
2D Toolkit => Support => Topic started 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?!
-
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;
-
How do I know - padding from tk2dTextMesh?
-
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.
-
I want to change the padding depending on the properties of the text tk2dTextMesh.
how do I do???????
-
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.
-
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
-
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
-
Thank you very much! It helped! :)