LogLayoutEntry() public static method

public static LogLayoutEntry ( Rect rect, RectOffset margins, GUIStyle style ) : void
rect Rect
margins RectOffset
style GUIStyle
return void
コード例 #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);
        }
コード例 #2
0
        static Rect DoGetRect(GUIContent content, GUIStyle style, GUILayoutOption[] options)
        {
            GUIUtility.CheckOnGUI();

            switch (Event.current.type)
            {
            case EventType.Layout:
                if (style.isHeightDependantOnWidth)
                {
                    current.topLevel.Add(new GUIWordWrapSizer(style, content, options));
                }
                else
                {
                    Vector2 sizeConstraints = new Vector2(0, 0);
                    if (options != null)
                    {
                        foreach (var option in options)
                        {
                            switch (option.type)
                            {
                            case GUILayoutOption.Type.maxHeight:
                                sizeConstraints.y = (float)option.value;
                                break;

                            case GUILayoutOption.Type.maxWidth:
                                sizeConstraints.x = (float)option.value;
                                break;
                            }
                        }
                    }

                    Vector2 size = style.CalcSizeWithConstraints(content, sizeConstraints);
                    // This is needed on non-integer scale ratios to avoid errors to accumulate in further layout calculations
                    size.x = Mathf.Ceil(size.x);
                    size.y = Mathf.Ceil(size.y);
                    current.topLevel.Add(new GUILayoutEntry(size.x, size.x, size.y, size.y, style, options));
                }
                return(kDummyRect);

            case EventType.Used:
                return(kDummyRect);

            default:
                var entry = current.topLevel.GetNext();
                GUIDebugger.LogLayoutEntry(entry.rect, entry.marginLeft, entry.marginRight, entry.marginTop, entry.marginBottom, entry.style);
                return(entry.rect);
            }
        }
コード例 #3
0
        static Rect DoGetRect(GUIContent content, GUIStyle style, GUILayoutOption[] options)
        {
            GUIUtility.CheckOnGUI();

            switch (Event.current.type)
            {
            case EventType.Layout:
                if (style.isHeightDependantOnWidth)
                {
                    current.topLevel.Add(new GUIWordWrapSizer(style, content, options));
                }
                else
                {
                    Vector2 sizeConstraints = new Vector2(0, 0);
                    if (options != null)
                    {
                        foreach (var option in options)
                        {
                            switch (option.type)
                            {
                            case GUILayoutOption.Type.maxHeight:
                                sizeConstraints.y = (float)option.value;
                                break;

                            case GUILayoutOption.Type.maxWidth:
                                sizeConstraints.x = (float)option.value;
                                break;
                            }
                        }
                    }

                    Vector2 size = style.CalcSizeWithConstraints(content, sizeConstraints);
                    current.topLevel.Add(new GUILayoutEntry(size.x, size.x, size.y, size.y, style, options));
                }
                return(kDummyRect);

            case EventType.Used:
                return(kDummyRect);

            default:
                var entry = current.topLevel.GetNext();
                GUIDebugger.LogLayoutEntry(entry.rect, entry.margin, entry.style);
                return(entry.rect);
            }
        }
コード例 #4
0
        private static Rect DoGetRect(GUIContent content, GUIStyle style, GUILayoutOption[] options)
        {
            GUIUtility.CheckOnGUI();
            switch (Event.current.type)
            {
            case EventType.Layout:
                if (style.isHeightDependantOnWidth)
                {
                    current.topLevel.Add(new GUIWordWrapSizer(style, content, options));
                }
                else
                {
                    Vector2 constraints = new Vector2(0f, 0f);
                    if (options != null)
                    {
                        foreach (GUILayoutOption option in options)
                        {
                            switch (option.type)
                            {
                            case GUILayoutOption.Type.maxHeight:
                                constraints.y = (float)option.value;
                                break;

                            case GUILayoutOption.Type.maxWidth:
                                constraints.x = (float)option.value;
                                break;
                            }
                        }
                    }
                    Vector2 vector2 = style.CalcSizeWithConstraints(content, constraints);
                    current.topLevel.Add(new GUILayoutEntry(vector2.x, vector2.x, vector2.y, vector2.y, style, options));
                }
                return(kDummyRect);

            case EventType.Used:
                return(kDummyRect);
            }
            GUILayoutEntry next = current.topLevel.GetNext();

            GUIDebugger.LogLayoutEntry(next.rect, next.margin, next.style);
            return(next.rect);
        }