Indie game storeFree gamesFun gamesHorror games
Game developmentAssetsComics
SalesBundles
Jobs
Tags

hsu99

8
Posts
1
Topics
A member registered Feb 02, 2022

Recent community posts

I also opened a new one of the sample project and changed the line, but it was the same.(?)  

(I used the sample sent before.)


OnRectTransformDimensionsChange is a function of UIBehaviour,and yes it is be called in SuperTextMesh.

I think this is a way to figure out how to fix the problem or find the cause. 

I’m glad I was able to help.

But because Canvas.ForceUpdateCanvases() will also change the rect and call OnRectTransformDimensionsChange() if rect changed.

In some cases, Rebuild() may be called many times before it reaches its final size.

Although it works but that is not a good solution if there has many objects need to be handled...

Hi,I changed the line 1606 from:

if(uiMode) LayoutRebuilder.ForceRebuildLayoutImmediate((RectTransform)tr.parent);

To:

if(uiMode) LayoutRebuilder.ForceRebuildLayoutImmediate((RectTransform)tr.root);

But it look like the problem still exists.  (Did I miss something?)


And about code  if(uiMode) LayoutRebuilder.MarkLayoutForRebuild(tr); 

,the update after one frame. (Maybe this,I used the MarkLayoutForRebuild of line 1604) 

I think that  is because the Rebuild() function called in the Update() function when rect changed.

But it  only woks in UNITY_EDITOR mode, not works in build. 


With the if(uiMode) LayoutRebuilder.MarkLayoutForRebuild(tr); added, 

and add the code below somewhere

void OnRectTransformDimensionsChange() {     
    if (uiMode) Rebuild(); 
}

it seems to work.


Hi, I've sent my sample project to your email.

And my Unity version is 2019.4.23f1.

I hope that can help.

The gif looks not update the rect of the changed text value. (?)


Oh...  sorry I think my title is  a little wrong...

 STM rect is not update properly with the text length changed in playing. (with something like layoutgroup control)     -->  This might be better.

should act like this(use default unity text):



And from the sample of my previous post,I noticed that STM  rect size actually changed. But it seems to have a delay. 

The first time text length changed,the rect of STM text seems to keep the previous size.

From the second time it updates to the right rect size.

(My temporarily action is just like Rebuild() one more time in OnRectTransformDimensionsChange() callback)

here is previous sample(use STM):


The OnRectTransformDimensionsChange() function of unity UIBehaviour may also help when parent layoutgroup try to change the child size.

It is called before Update().

https://docs.unity3d.com/2018.4/Documentation/ScriptReference/EventSystems.UIBeh...

Wish to see this problem being solved in future version.  Many many thanks! :) 

(1 edit)

Yes I tried to add the "content size fitter" to the STM object but it seems not to work properly...


And I made a simple example of this case and hope this could help to figure out the problem. 

Here is my ui setting:


I also recorded the video of "STM Sample"(use STM text) and "Default Text Sample"(use unity default text). 

(The STM version I used  in this sample is 1.12.0, and I comment out the rect update in Editor mode to make sure it works as the build.)

And the result I want is as the demo of "Default Text".

sample video download link(available in 7 days, unzip pw:stm): https://firestorage.jp/download/87217ba5b9b682fa109a2f8eae240cabdc6a2406

Hi,it seems that the wrap size of STM text is not update correctly when the recttransform size changed in playing.

I used the horizontal/vertical layoutgroup and checked Control Child Size to auto layout the ui component(STM text).

But turning the gameobject off and on again got the right size.  

Because some object will be reused for better performence. (change text value of the same ui object like scroll view cell...etc)

Currently we used OnRectTransformDimensionsChange() to detect the rect changing and call Rebuild() function in it to avoid this problem.(Maybe there will be other way to solve it.)

Because we always want to keep the STM version to be the newest,it will be very helpful if this problem can be solved in the future update.