美文网首页
content size fiiter没刷新的问题

content size fiiter没刷新的问题

作者: ValiaLee | 来源:发表于2018-11-02 21:04 被阅读0次

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 

相关文章

网友评论

      本文标题:content size fiiter没刷新的问题

      本文链接:https://www.haomeiwen.com/subject/tzqhxqtx.html