content size fiiter没刷新的问题

2018-11-02  本文已影响0人  ValiaLee

Hi there. I had a very similar setup for tooltips with the same issue. This solved my problem:

Code (CSharp):

tooltTipText = "new tooltip \n second row";

Canvas.ForceUpdateCanvases(); // *

tooltTipText.transform.parent.GetComponent<HorizontalLayoutGroup>().enabled = false; // **

tooltTipText.transform.parent.GetComponent<HorizontalLayoutGroup>().enabled = true;

* According to documentation, a canvas (which controls your UI elements) performs its layout and content generation calculations at the end of a frame, just before rendering, in order to ensure that it's based on all the latest changes that may have happened during that frame. Code that relies on up-to-date layout or content can call Canvas.ForceUpdateCanvasaes() to ensure it before executing code that relies on it. 

** Sometimes the reenabling of the HorizontalLayoutGroup or VercticalLayoutGroup is also needed, but it depends on your configuration.

Cheers 

上一篇 下一篇

猜你喜欢

热点阅读