Popup() private method

private Popup ( Rect position, int selectedIndex ) : void
position UnityEngine.Rect
selectedIndex int
return void
Example #1
0
        private bool ShowModePopup(Rect popupRect)
        {
            int umbraDataSize = StaticOcclusionCulling.umbraDataSize;

            if (this.m_PreVis != StaticOcclusionCullingVisualization.showPreVisualization)
            {
                SceneView.RepaintAll();
            }
            if (Event.current.type == EventType.Layout)
            {
                this.m_PreVis = StaticOcclusionCullingVisualization.showPreVisualization;
            }
            string[] strArray = new string[2] {
                "Edit", "Visualize"
            };
            int selectedIndex = !this.m_PreVis ? 1 : 0;

            if (EditorGUI.ButtonMouseDown(popupRect, new GUIContent(strArray[selectedIndex]), FocusType.Passive, EditorStyles.popup))
            {
                GenericMenu genericMenu = new GenericMenu();
                genericMenu.AddItem(new GUIContent(strArray[0]), selectedIndex == 0, new GenericMenu.MenuFunction(this.SetShowVolumePreVis));
                if (umbraDataSize > 0)
                {
                    genericMenu.AddItem(new GUIContent(strArray[1]), selectedIndex == 1, new GenericMenu.MenuFunction(this.SetShowVolumeCulling));
                }
                else
                {
                    genericMenu.AddDisabledItem(new GUIContent(strArray[1]));
                }
                genericMenu.Popup(popupRect, selectedIndex);
            }
            return(this.m_PreVis);
        }
        bool ShowModePopup(Rect popupRect)
        {
            // Visualization mode popup
            int tomeSize = StaticOcclusionCulling.umbraDataSize;

            // We can only change the preVis state during layout mode. However, the Tome data could be emptied at anytime, which will immediately disable preVis.
            // We need to detect this and force a repaint, so we can change the state.
            if (m_PreVis != StaticOcclusionCullingVisualization.showPreVisualization)
            {
                SceneView.RepaintAll();
            }

            if (Event.current.type == EventType.Layout)
            {
                m_PreVis = StaticOcclusionCullingVisualization.showPreVisualization;
            }

            string[] options  = new string[] { "Edit", "Visualize" };
            int      selected = m_PreVis ? 0 : 1;

            if (EditorGUI.DropdownButton(popupRect, new GUIContent(options[selected]), FocusType.Passive, EditorStyles.popup))
            {
                GenericMenu menu = new GenericMenu();
                menu.AddItem(new GUIContent(options[0]), selected == 0, SetShowVolumePreVis);
                if (tomeSize > 0)
                {
                    menu.AddItem(new GUIContent(options[1]), selected == 1, SetShowVolumeCulling);
                }
                else
                {
                    menu.AddDisabledItem(new GUIContent(options[1]));
                }

                menu.Popup(popupRect, selected);
            }
            return(m_PreVis);
        }
 private bool ShowModePopup(Rect popupRect)
 {
   int umbraDataSize = StaticOcclusionCulling.umbraDataSize;
   if (this.m_PreVis != StaticOcclusionCullingVisualization.showPreVisualization)
     SceneView.RepaintAll();
   if (Event.current.type == EventType.Layout)
     this.m_PreVis = StaticOcclusionCullingVisualization.showPreVisualization;
   string[] strArray = new string[2]{ "Edit", "Visualize" };
   int selectedIndex = !this.m_PreVis ? 1 : 0;
   if (EditorGUI.ButtonMouseDown(popupRect, new GUIContent(strArray[selectedIndex]), FocusType.Passive, EditorStyles.popup))
   {
     GenericMenu genericMenu = new GenericMenu();
     genericMenu.AddItem(new GUIContent(strArray[0]), selectedIndex == 0, new GenericMenu.MenuFunction(this.SetShowVolumePreVis));
     if (umbraDataSize > 0)
       genericMenu.AddItem(new GUIContent(strArray[1]), selectedIndex == 1, new GenericMenu.MenuFunction(this.SetShowVolumeCulling));
     else
       genericMenu.AddDisabledItem(new GUIContent(strArray[1]));
     genericMenu.Popup(popupRect, selectedIndex);
   }
   return this.m_PreVis;
 }
 public void AddButton(Rect rect, ReorderableList list)
 {
   GenericMenu genericMenu = new GenericMenu();
   genericMenu.AddItem(new GUIContent("Add Motion Field"), false, new GenericMenu.MenuFunction(this.AddChildAnimation));
   genericMenu.AddItem(EditorGUIUtility.TempContent("New Blend Tree"), false, new GenericMenu.MenuFunction(this.AddBlendTreeCallback));
   genericMenu.Popup(rect, 0);
 }