public override void OnPreviewGUI(Rect r, GUIStyle background)
        {
            if (Event.current.type != EventType.Repaint)
            {
                return;
            }
            if (this.m_Styles == null)
            {
                this.m_Styles = new LayoutPropertiesPreview.Styles();
            }
            RectTransform transform = (this.target as GameObject).transform as RectTransform;

            if ((UnityEngine.Object)transform == (UnityEngine.Object)null)
            {
                return;
            }
            r        = new RectOffset(-5, -5, -5, -5).Add(r);
            r.height = EditorGUIUtility.singleLineHeight;
            Rect labelRect  = r;
            Rect valueRect  = r;
            Rect sourceRect = r;

            labelRect.width  = 110f;
            valueRect.xMin  += 110f;
            valueRect.width  = 100f;
            sourceRect.xMin += 210f;
            GUI.Label(labelRect, "Property", this.m_Styles.headerStyle);
            GUI.Label(valueRect, "Value", this.m_Styles.headerStyle);
            GUI.Label(sourceRect, "Source", this.m_Styles.headerStyle);
            labelRect.y  += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
            valueRect.y  += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
            sourceRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
            ILayoutElement source = (ILayoutElement)null;

            this.ShowProp(ref labelRect, ref valueRect, ref sourceRect, "Min Width", LayoutUtility.GetLayoutProperty(transform, (Func <ILayoutElement, float>)(e => e.minWidth), 0.0f, out source).ToString(), source);
            this.ShowProp(ref labelRect, ref valueRect, ref sourceRect, "Min Height", LayoutUtility.GetLayoutProperty(transform, (Func <ILayoutElement, float>)(e => e.minHeight), 0.0f, out source).ToString(), source);
            this.ShowProp(ref labelRect, ref valueRect, ref sourceRect, "Preferred Width", LayoutUtility.GetLayoutProperty(transform, (Func <ILayoutElement, float>)(e => e.preferredWidth), 0.0f, out source).ToString(), source);
            this.ShowProp(ref labelRect, ref valueRect, ref sourceRect, "Preferred Height", LayoutUtility.GetLayoutProperty(transform, (Func <ILayoutElement, float>)(e => e.preferredHeight), 0.0f, out source).ToString(), source);
            float layoutProperty1 = LayoutUtility.GetLayoutProperty(transform, (Func <ILayoutElement, float>)(e => e.flexibleWidth), 0.0f, out source);

            this.ShowProp(ref labelRect, ref valueRect, ref sourceRect, "Flexible Width", (double)layoutProperty1 <= 0.0 ? "disabled" : "enabled (" + layoutProperty1.ToString() + ")", source);
            float layoutProperty2 = LayoutUtility.GetLayoutProperty(transform, (Func <ILayoutElement, float>)(e => e.flexibleHeight), 0.0f, out source);

            this.ShowProp(ref labelRect, ref valueRect, ref sourceRect, "Flexible Height", (double)layoutProperty2 <= 0.0 ? "disabled" : "enabled (" + layoutProperty2.ToString() + ")", source);
            if ((bool)((UnityEngine.Object)transform.GetComponent <LayoutElement>()))
            {
                return;
            }
            GUI.Label(new Rect(labelRect.x, labelRect.y + 10f, r.width, EditorGUIUtility.singleLineHeight), "Add a LayoutElement to override values.", this.m_Styles.labelStyle);
        }
예제 #2
0
 public override void OnPreviewGUI(Rect r, GUIStyle background)
 {
     if (Event.current.type == EventType.Repaint)
     {
         if (this.m_Styles == null)
         {
             this.m_Styles = new LayoutPropertiesPreview.Styles();
         }
         GameObject    gameObject    = this.target as GameObject;
         RectTransform rectTransform = gameObject.transform as RectTransform;
         if (!(rectTransform == null))
         {
             RectOffset rectOffset = new RectOffset(-5, -5, -5, -5);
             r        = rectOffset.Add(r);
             r.height = EditorGUIUtility.singleLineHeight;
             Rect position  = r;
             Rect position2 = r;
             Rect position3 = r;
             position.width  = 110f;
             position2.xMin += 110f;
             position2.width = 100f;
             position3.xMin += 210f;
             GUI.Label(position, "Property", this.m_Styles.headerStyle);
             GUI.Label(position2, "Value", this.m_Styles.headerStyle);
             GUI.Label(position3, "Source", this.m_Styles.headerStyle);
             position.y  += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
             position2.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
             position3.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
             ILayoutElement source = null;
             this.ShowProp(ref position, ref position2, ref position3, "Min Width", LayoutUtility.GetLayoutProperty(rectTransform, (ILayoutElement e) => e.minWidth, 0f, out source).ToString(), source);
             this.ShowProp(ref position, ref position2, ref position3, "Min Height", LayoutUtility.GetLayoutProperty(rectTransform, (ILayoutElement e) => e.minHeight, 0f, out source).ToString(), source);
             this.ShowProp(ref position, ref position2, ref position3, "Preferred Width", LayoutUtility.GetLayoutProperty(rectTransform, (ILayoutElement e) => e.preferredWidth, 0f, out source).ToString(), source);
             this.ShowProp(ref position, ref position2, ref position3, "Preferred Height", LayoutUtility.GetLayoutProperty(rectTransform, (ILayoutElement e) => e.preferredHeight, 0f, out source).ToString(), source);
             float layoutProperty = LayoutUtility.GetLayoutProperty(rectTransform, (ILayoutElement e) => e.flexibleWidth, 0f, out source);
             this.ShowProp(ref position, ref position2, ref position3, "Flexible Width", (layoutProperty <= 0f) ? "disabled" : ("enabled (" + layoutProperty.ToString() + ")"), source);
             layoutProperty = LayoutUtility.GetLayoutProperty(rectTransform, (ILayoutElement e) => e.flexibleHeight, 0f, out source);
             this.ShowProp(ref position, ref position2, ref position3, "Flexible Height", (layoutProperty <= 0f) ? "disabled" : ("enabled (" + layoutProperty.ToString() + ")"), source);
             if (!rectTransform.GetComponent <LayoutElement>())
             {
                 Rect position4 = new Rect(position.x, position.y + 10f, r.width, EditorGUIUtility.singleLineHeight);
                 GUI.Label(position4, "Add a LayoutElement to override values.", this.m_Styles.labelStyle);
             }
         }
     }
 }
 public override void OnPreviewGUI(Rect r, GUIStyle background)
 {
   if (Event.current.type != EventType.Repaint)
     return;
   if (this.m_Styles == null)
     this.m_Styles = new LayoutPropertiesPreview.Styles();
   RectTransform transform = (this.target as GameObject).transform as RectTransform;
   if ((UnityEngine.Object) transform == (UnityEngine.Object) null)
     return;
   r = new RectOffset(-5, -5, -5, -5).Add(r);
   r.height = EditorGUIUtility.singleLineHeight;
   Rect labelRect = r;
   Rect valueRect = r;
   Rect sourceRect = r;
   labelRect.width = 110f;
   valueRect.xMin += 110f;
   valueRect.width = 100f;
   sourceRect.xMin += 210f;
   GUI.Label(labelRect, "Property", this.m_Styles.headerStyle);
   GUI.Label(valueRect, "Value", this.m_Styles.headerStyle);
   GUI.Label(sourceRect, "Source", this.m_Styles.headerStyle);
   labelRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
   valueRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
   sourceRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
   ILayoutElement source = (ILayoutElement) null;
   this.ShowProp(ref labelRect, ref valueRect, ref sourceRect, "Min Width", LayoutUtility.GetLayoutProperty(transform, (Func<ILayoutElement, float>) (e => e.minWidth), 0.0f, out source).ToString(), source);
   this.ShowProp(ref labelRect, ref valueRect, ref sourceRect, "Min Height", LayoutUtility.GetLayoutProperty(transform, (Func<ILayoutElement, float>) (e => e.minHeight), 0.0f, out source).ToString(), source);
   this.ShowProp(ref labelRect, ref valueRect, ref sourceRect, "Preferred Width", LayoutUtility.GetLayoutProperty(transform, (Func<ILayoutElement, float>) (e => e.preferredWidth), 0.0f, out source).ToString(), source);
   this.ShowProp(ref labelRect, ref valueRect, ref sourceRect, "Preferred Height", LayoutUtility.GetLayoutProperty(transform, (Func<ILayoutElement, float>) (e => e.preferredHeight), 0.0f, out source).ToString(), source);
   float layoutProperty1 = LayoutUtility.GetLayoutProperty(transform, (Func<ILayoutElement, float>) (e => e.flexibleWidth), 0.0f, out source);
   this.ShowProp(ref labelRect, ref valueRect, ref sourceRect, "Flexible Width", (double) layoutProperty1 <= 0.0 ? "disabled" : "enabled (" + layoutProperty1.ToString() + ")", source);
   float layoutProperty2 = LayoutUtility.GetLayoutProperty(transform, (Func<ILayoutElement, float>) (e => e.flexibleHeight), 0.0f, out source);
   this.ShowProp(ref labelRect, ref valueRect, ref sourceRect, "Flexible Height", (double) layoutProperty2 <= 0.0 ? "disabled" : "enabled (" + layoutProperty2.ToString() + ")", source);
   if ((bool) ((UnityEngine.Object) transform.GetComponent<LayoutElement>()))
     return;
   GUI.Label(new Rect(labelRect.x, labelRect.y + 10f, r.width, EditorGUIUtility.singleLineHeight), "Add a LayoutElement to override values.", this.m_Styles.labelStyle);
 }