title: Unity: Can't find UI Layout Element Max Size
body: <p>In Unity UI, LayoutElement has a min, prefered and flxible size, but it do not have a max size property.</p>
  
  <p>For example if I have a <code>text1</code> and</p>
  
  <pre><code>layoutElement.flxibleWith = 1
  layoutElement.minHeight  = 19
  </code></pre>
  
  <p><code>text1</code> with one line txt:</p>
  
  <p><a href="https://i.stack.imgur.com/GF1EN.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/GF1EN.png" alt="text1 with one line txt"></a></p>
  
  <p>But when I load text in <code>text1</code> it continues spreading it height with no limits:</p>
  
  <p><a href="https://i.stack.imgur.com/2JhC5.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/2JhC5.png" alt="enter image description here"></a></p>
  
  <p>I have made a script:</p>
  
  <pre><code>using UnityEngine;
  using System.Collections;
  using UnityEngine.UI;
  
  [ExecuteInEditMode]
  [RequireComponent(typeof(LayoutElement))]
  
  public class LayoutElementMaxSize : MonoBehaviour
  {
  
  private LayoutElement layoutElement;
  private ContentSizeFitter contentSizeFitter;
  private RectTransform rectransform;
  
  public bool controllWidth;
  public bool controllHeight;
  
  public float maxHight;
  public float maxWidth;
  
  void Start()
  {
      layoutElement = GetComponent&lt;LayoutElement&gt;();
      rectransform = GetComponent&lt;RectTransform&gt;();
  }
  
  public void Update()
  {
      if(rectransform.hasChanged)
       {
          rectransform.hasChanged = false;
  
          if (controllHeight)
          {
              layoutElement.preferredHeight = -1;
  
              layoutElement.CalculateLayoutInputHorizontal();
              layoutElement.CalculateLayoutInputVertical();
  
              if (rectransform.rect.height &gt;= maxHight)
              {
                  layoutElement.preferredHeight = maxHight;
              }
          }
  
          if (controllWidth)
          {
              if (rectransform.rect.height &gt;= maxWidth)
              {
                  layoutElement.preferredWidth = maxWidth;
              }
              else
              {
                  layoutElement.preferredWidth = -1;
              }
          }
      }
  }}
  </code></pre>
  
  <p>but it is not full filing my requirement plz take a look on it .. </p>