content size fiiter没刷新的问题

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().enabled = false; // **

tooltTipText.transform.parent.GetComponent().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没刷新的问题)