UnityEngine.GUIStyle.CalcSizeWithConstraints C# (CSharp) Method

CalcSizeWithConstraints() private method

private CalcSizeWithConstraints ( GUIContent content, Vector2 constraints ) : Vector2
content GUIContent
constraints Vector2
return Vector2
        internal Vector2 CalcSizeWithConstraints(GUIContent content, Vector2 constraints)
        {
            Vector2 vector;
            Internal_CalcSizeWithConstraints(this.m_Ptr, content, constraints, out vector);
            return vector;
        }

Usage Example

コード例 #1
0
        private static Rect DoGetRect(GUIContent content, GUIStyle style, GUILayoutOption[] options)
        {
            GUIUtility.CheckOnGUI();
            EventType type      = Event.current.type;
            EventType eventType = type;
            Rect      rect;

            if (eventType != EventType.Layout)
            {
                if (eventType != EventType.Used)
                {
                    GUILayoutEntry next = GUILayoutUtility.current.topLevel.GetNext();
                    GUIDebugger.LogLayoutEntry(next.rect, next.marginLeft, next.marginRight, next.marginTop, next.marginBottom, next.style);
                    rect = next.rect;
                }
                else
                {
                    rect = GUILayoutUtility.kDummyRect;
                }
            }
            else
            {
                bool isHeightDependantOnWidth = style.isHeightDependantOnWidth;
                if (isHeightDependantOnWidth)
                {
                    GUILayoutUtility.current.topLevel.Add(new GUIWordWrapSizer(style, content, options));
                }
                else
                {
                    Vector2 constraints = new Vector2(0f, 0f);
                    bool    flag        = options != null;
                    if (flag)
                    {
                        for (int i = 0; i < options.Length; i++)
                        {
                            GUILayoutOption      gUILayoutOption = options[i];
                            GUILayoutOption.Type type2           = gUILayoutOption.type;
                            GUILayoutOption.Type type3           = type2;
                            if (type3 != GUILayoutOption.Type.maxWidth)
                            {
                                if (type3 == GUILayoutOption.Type.maxHeight)
                                {
                                    constraints.y = (float)gUILayoutOption.value;
                                }
                            }
                            else
                            {
                                constraints.x = (float)gUILayoutOption.value;
                            }
                        }
                    }
                    Vector2 vector = style.CalcSizeWithConstraints(content, constraints);
                    vector.x = Mathf.Ceil(vector.x);
                    vector.y = Mathf.Ceil(vector.y);
                    GUILayoutUtility.current.topLevel.Add(new GUILayoutEntry(vector.x, vector.x, vector.y, vector.y, style, options));
                }
                rect = GUILayoutUtility.kDummyRect;
            }
            return(rect);
        }
All Usage Examples Of UnityEngine.GUIStyle::CalcSizeWithConstraints