Ejemplo n.º 1
0
    // Token: 0x06000916 RID: 2326 RVA: 0x00039DF8 File Offset: 0x00037FF8
    public static int Toolbar(Rect position, int selected, GUIContent[] contents, int xCount, GUIStyle style)
    {
        int       result         = GUI.Toolbar(position, selected, contents, style);
        int       controlID      = GUIUtility.GetControlID(FocusType.Native, position);
        EventType typeForControl = Event.current.GetTypeForControl(controlID);

        if (typeForControl == EventType.Repaint)
        {
            GUIStyle firstStyle = null;
            GUIStyle midStyle   = null;
            GUIStyle lastStyle  = null;
            UnityGUI.FindStyles(ref style, out firstStyle, out midStyle, out lastStyle, "left", "mid", "right");
            int num  = contents.Length;
            int num2 = num / xCount;
            if (num % xCount != 0)
            {
                num2++;
            }
            float  num3        = (float)UnityGUI.CalcTotalHorizSpacing(xCount, style, firstStyle, midStyle, lastStyle);
            float  num4        = (float)(Mathf.Max(style.margin.top, style.margin.bottom) * (num2 - 1));
            float  elemWidth   = (position.width - num3) / (float)xCount;
            float  elemHeight  = (position.height - num4) / (float)num2;
            Rect[] buttonRects = UnityGUI.CalcMouseRects(position, num, xCount, elemWidth, elemHeight, style, firstStyle, midStyle, lastStyle, false);
            int    buttonGridMouseSelection = UnityGUI.GetButtonGridMouseSelection(buttonRects, Event.current.mousePosition, controlID == GUIUtility.hotControl);
            if (buttonGridMouseSelection >= 0)
            {
                GUI.tooltip = contents[buttonGridMouseSelection].tooltip;
            }
        }
        return(result);
    }