Esempio n. 1
0
 private static void SelectionCallback(object userData)
 {
     ExposablePopupMenu.ItemData item = (ExposablePopupMenu.ItemData)userData;
     ExposablePopupMenu.PopUpMenu.m_Caller.SelectionChanged(item);
     ExposablePopupMenu.PopUpMenu.m_Caller = null;
     ExposablePopupMenu.PopUpMenu.m_Data   = null;
 }
Esempio n. 2
0
 public float OnGUI(Rect rect)
 {
     if ((double)rect.width >= (double)this.m_WidthOfButtons && (double)rect.width > (double)this.m_MinWidthOfPopup)
     {
         Rect position = rect;
         using (List <ExposablePopupMenu.ItemData> .Enumerator enumerator = this.m_Items.GetEnumerator())
         {
             while (enumerator.MoveNext())
             {
                 ExposablePopupMenu.ItemData current = enumerator.Current;
                 position.width = current.m_Width;
                 EditorGUI.BeginChangeCheck();
                 EditorGUI.BeginDisabledGroup(!current.m_Enabled);
                 GUI.Toggle(position, current.m_On, current.m_GUIContent, current.m_Style);
                 EditorGUI.EndDisabledGroup();
                 if (EditorGUI.EndChangeCheck())
                 {
                     this.SelectionChanged(current);
                     GUIUtility.ExitGUI();
                 }
                 position.x += current.m_Width + this.m_ItemSpacing;
             }
         }
         return(this.m_WidthOfButtons);
     }
     if ((double)this.m_WidthOfPopup < (double)rect.width)
     {
         rect.width = this.m_WidthOfPopup;
     }
     if (EditorGUI.ButtonMouseDown(rect, this.m_PopupButtonData.m_GUIContent, FocusType.Passive, this.m_PopupButtonData.m_Style))
     {
         ExposablePopupMenu.PopUpMenu.Show(rect, this.m_Items, this);
     }
     return(this.m_WidthOfPopup);
 }
Esempio n. 3
0
 private void SelectionChanged(ExposablePopupMenu.ItemData item)
 {
     if (this.m_SelectionChangedCallback != null)
     {
         this.m_SelectionChangedCallback(item);
     }
     else
     {
         Debug.LogError("Callback is null");
     }
 }
Esempio n. 4
0
        private void CalcWidths()
        {
            this.m_WidthOfButtons = 0.0f;
            using (List <ExposablePopupMenu.ItemData> .Enumerator enumerator = this.m_Items.GetEnumerator())
            {
                while (enumerator.MoveNext())
                {
                    ExposablePopupMenu.ItemData current = enumerator.Current;
                    current.m_Width        = current.m_Style.CalcSize(current.m_GUIContent).x;
                    this.m_WidthOfButtons += current.m_Width;
                }
            }
            this.m_WidthOfButtons += (float)(this.m_Items.Count - 1) * this.m_ItemSpacing;
            Vector2 vector2 = this.m_PopupButtonData.m_Style.CalcSize(this.m_PopupButtonData.m_GUIContent);

            vector2.x          += 3f;
            this.m_WidthOfPopup = vector2.x;
        }
Esempio n. 5
0
            internal static void Show(Rect activatorRect, List <ExposablePopupMenu.ItemData> buttonData, ExposablePopupMenu caller)
            {
                ExposablePopupMenu.PopUpMenu.m_Data   = buttonData;
                ExposablePopupMenu.PopUpMenu.m_Caller = caller;
                GenericMenu genericMenu = new GenericMenu();

                using (List <ExposablePopupMenu.ItemData> .Enumerator enumerator = ExposablePopupMenu.PopUpMenu.m_Data.GetEnumerator())
                {
                    while (enumerator.MoveNext())
                    {
                        ExposablePopupMenu.ItemData current = enumerator.Current;
                        if (current.m_Enabled)
                        {
                            genericMenu.AddItem(current.m_GUIContent, current.m_On, new GenericMenu.MenuFunction2(ExposablePopupMenu.PopUpMenu.SelectionCallback), (object)current);
                        }
                        else
                        {
                            genericMenu.AddDisabledItem(current.m_GUIContent);
                        }
                    }
                }
                genericMenu.DropDown(activatorRect);
            }