Пример #1
0
 private void CalcTextPreferredWidth()
 {
     //这里很无奈,UGUI中文字只有渲染过后才能拿到正确的preferredWidth
     //所以这里延迟1帧再进行赋值
     taskDelay?.Release();
     if (this.HorizontalOverflow == HorizontalWrapMode.Overflow && this.VerticalOverflow == VerticalWrapMode.Overflow)
     {
         taskDelay = TaskLite.Invoke(t =>
         {
             //Debug.Log($"after one frame  {textComponent.preferredWidth}   {textComponent.preferredHeight}");
             if (this != null && textComponent != null)
             {
                 Size = new Vector2(textComponent.preferredWidth, textComponent.preferredHeight);
             }
             taskDelay = null;
             return(true);
         });
     }
 }
 public void Pause()
 {
     animationTask?.Release();
     animationTask = null;
     isPlaying     = false;
 }