public void Init(Rect buttonRect)
        {
            m_ButtonRectScreenPos = EditorGUIUtility.GUIToScreenRect(buttonRect);
            if (m_State == null)
            {
                m_State = new AdvancedDropdownState();
            }
            if (m_DataSource == null)
            {
                m_DataSource = new MultiLevelDataSource();
            }
            if (m_Gui == null)
            {
                m_Gui = new AdvancedDropdownGUI(m_DataSource);
            }
            m_Gui.state = m_State;

            // Has to be done before calling Show / ShowWithMode
            buttonRect = GUIUtility.GUIToScreenRect(buttonRect);
            OnDirtyList();
            m_CurrentlyRenderedTree = hasSearch ? m_DataSource.searchTree : m_DataSource.mainTree;
            ShowAsDropDown(buttonRect, CalculateWindowSize(buttonRect), GetLocationPriority());
            if (setInitialSelectionPosition)
            {
                m_InitialSelectionPosition = m_Gui.GetSelectionHeight(m_DataSource, buttonRect);
            }
            wantsMouseMove = true;
            SetSelectionFromState();
        }
        private void SetupFilters()
        {
            filtersMenu.ShowTextTooltipOnSizeChange(-16);

            filtersMenu.clickable.clicked += () =>
            {
                if (PackageManagerFiltersWindow.instance != null)
                {
                    return;
                }

                var page = PageManager.instance.GetCurrentPage();
                if (page != null && PackageManagerFiltersWindow.ShowAtPosition(GUIUtility.GUIToScreenRect(filtersMenu.worldBound), page.tab, page.filters))
                {
                    filtersMenu.pseudoStates |= PseudoStates.Active;
                    PackageManagerFiltersWindow.instance.OnFiltersChanged += filters =>
                    {
                        UpdateFiltersMenuText(filters);
                        page.UpdateFilters(filters);
                    };
                    PackageManagerFiltersWindow.instance.OnClose += () =>
                    {
                        filtersMenu.pseudoStates &= ~PseudoStates.Active;
                    };
                }
            };
            clearFiltersButton.clickable.clicked += () =>
            {
                var page = PageManager.instance.GetCurrentPage();
                page.ClearFilters();
                UpdateFiltersMenuText(page.filters);
            };
        }
Пример #3
0
        public void OnGUI(Rect connectRect, GUIContent profilerLabel)
        {
            if (!EditorGUI.ButtonMouseDown(connectRect, profilerLabel, FocusType.Native, EditorStyles.toolbarDropDown))
            {
                return;
            }
            List <ProfilerChoise> profilerChoiseList = new List <ProfilerChoise>();

            profilerChoiseList.Clear();
            AttachProfilerUI.AddPlayerProfilers(profilerChoiseList);
            AttachProfilerUI.AddDeviceProfilers(profilerChoiseList);
            AttachProfilerUI.AddLastIPProfiler(profilerChoiseList);
            this.AddEnterIPProfiler(profilerChoiseList, GUIUtility.GUIToScreenRect(connectRect));
            string[] array1 = profilerChoiseList.Select <ProfilerChoise, string>((Func <ProfilerChoise, string>)(p => p.Name)).ToArray <string>();
            bool[]   array2 = profilerChoiseList.Select <ProfilerChoise, bool>((Func <ProfilerChoise, bool>)(p => p.Enabled)).ToArray <bool>();
            int      index  = profilerChoiseList.FindIndex((Predicate <ProfilerChoise>)(p => p.IsSelected()));

            int[] selected;
            if (index == -1)
            {
                selected = new int[0];
            }
            else
            {
                selected = new int[1] {
                    index
                }
            };
            EditorUtility.DisplayCustomMenu(connectRect, array1, array2, selected, new EditorUtility.SelectMenuItemFunction(this.SelectProfilerClick), (object)profilerChoiseList);
        }
    }
Пример #4
0
 public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
 {
     if (typeof(ItemBase).IsAssignableFrom(fieldInfo.FieldType))
     {
         bool  emptyLable = string.IsNullOrEmpty(label.text);
         float labelWidth = emptyLable ? 0 : EditorGUIUtility.labelWidth;
         EditorGUI.LabelField(new Rect(position.x, position.y, labelWidth, EditorGUIUtility.singleLineHeight), label);
         var buttonRect = new Rect(position.x + (emptyLable ? 0 : labelWidth + 2), position.y, position.width - labelWidth - (emptyLable ? 25 : 27), EditorGUIUtility.singleLineHeight);
         var item       = property.objectReferenceValue as ItemBase;
         if (GUI.Button(buttonRect, new GUIContent(item ? item.Name : "未选择")
         {
             image = item ? (item.Icon ? item.Icon.texture : null) : null
         }, EditorStyles.popup))
         {
             ItemSearchProvider.OpenWindow(new SearchWindowContext(GUIUtility.GUIToScreenRect(buttonRect).position),
                                           ZetanUtility.Editor.LoadAssets <ItemBase>(),
                                           i => { property.objectReferenceValue = i; property.serializedObject.ApplyModifiedProperties(); });
         }
         EditorGUI.PropertyField(new Rect(position.x + position.width - 23f, position.y, 23f, EditorGUIUtility.singleLineHeight), property, new GUIContent(string.Empty));
     }
     else
     {
         EditorGUI.PropertyField(position, property, label);
     }
 }
        private void Init(Vector2 pos, List <InputData> data, OnSelectCallback callback)
        {
            Rect guiRect = new Rect(pos.x, pos.y - 16f, 16f, 16f);

            guiRect = GUIUtility.GUIToScreenRect(guiRect);
            if (< > f__am$cache0 == null)
            {
Пример #6
0
 void Init(Rect buttonRect, GridPaintPaletteWindow owner)
 {
     m_Owner    = owner;
     m_CellSize = new Vector3(1, 1, 0);
     buttonRect = GUIUtility.GUIToScreenRect(buttonRect);
     ShowAsDropDown(buttonRect, new Vector2(312, 150), null, ShowMode.PopupMenuWithKeyboardFocus);
 }
Пример #7
0
 private void Init(Rect buttonRect, GridPaintPaletteWindow owner)
 {
     this.m_Owner    = owner;
     this.m_CellSize = new Vector3(1f, 1f, 0f);
     buttonRect      = GUIUtility.GUIToScreenRect(buttonRect);
     base.ShowAsDropDown(buttonRect, new Vector2(312f, 140f), null, ShowMode.PopupMenuWithKeyboardFocus);
 }
        internal MaterialHierarchyPopup(Object[] targets, bool enabled, MaterialEditor materialEditor, Rect activatorRect)
        {
            this.enabled        = enabled;
            this.materialEditor = materialEditor;
            target     = targets[0] as Material;
            targetGUID = AssetDatabase.GUIDFromAssetPath(AssetDatabase.GetAssetPath(target));

            targetPositionY = singleLinePositionY = GUIUtility.GUIToScreenRect(activatorRect).yMax;
            if (target.isVariant || materialEditor.convertState == ConvertAction.Convert)
            {
                singleLinePositionY -= k_PositionShiftY;
            }

            k_MinNameWidth = k_MinWindowWidth - (k_TitleWidth + k_SplitWidth + k_OverridesWidth + k_LocksWidth);

            searchFilter = new SearchFilter()
            {
                classNames = new string[] { "Material" },
                searchArea = SearchFilter.SearchArea.AllAssets
            };
            debounce = Delayer.Debounce(_ =>
            {
                SearchFilterChanged();
                editorWindow.Repaint();
            });

            Init();
        }
        static bool IsGUIRectVisible(Rect guiRect)
        {
            var screenRect = GUIUtility.GUIToScreenRect(guiRect);
            var halfHeight = screenRect.height / 2f;

            return(screenRect.y > -halfHeight && screenRect.y < ((Screen.height / EditorGUIUtility.pixelsPerPoint) + halfHeight));
        }
Пример #10
0
        void Init(Object targetObj, Rect activatorRect, bool showLabelIcons)
        {
            m_TargetObject   = targetObj;
            m_StartIcon      = EditorGUIUtility.GetIconForObject(m_TargetObject);
            m_ShowLabelIcons = showLabelIcons;
            Rect screenActivatorRect = GUIUtility.GUIToScreenRect(activatorRect);

            // Remove any keyboard control when opening this window
            GUIUtility.keyboardControl = 0;

            // Init GUIContents
            m_LabelLargeIcons        = GetTextures("sv_label_", "", 0, 8);
            m_LabelIcons             = GetTextures("sv_icon_name", "", 0, 8);
            m_SmallIcons             = GetTextures("sv_icon_dot", "_sml", 0, 16);
            m_LargeIcons             = GetTextures("sv_icon_dot", "_pix16_gizmo", 0, 16);
            m_NoneButtonContent      = EditorGUIUtility.IconContent("sv_icon_none");
            m_NoneButtonContent.text = "None";

            // Deal with window size
            float k_Width  = 140;
            float k_Height = 86;

            if (m_ShowLabelIcons)
            {
                k_Height = 126;
            }

            ShowAsDropDown(screenActivatorRect, new Vector2(k_Width, k_Height));
        }
Пример #11
0
        internal static bool ShowCenteredAtPosition(Rect buttonRect)
        {
            buttonRect.x -= 160f;
            long num = DateTime.Now.Ticks / 10000L;
            bool result;

            if (num >= CollabToolbarWindow.s_LastClosedTime + 50L)
            {
                if (Event.current.type != EventType.Layout)
                {
                    Event.current.Use();
                }
                if (CollabToolbarWindow.s_CollabToolbarWindow == null)
                {
                    CollabToolbarWindow.s_CollabToolbarWindow = ScriptableObject.CreateInstance <CollabToolbarWindow>();
                }
                buttonRect = GUIUtility.GUIToScreenRect(buttonRect);
                Vector2 windowSize = new Vector2(320f, 350f);
                CollabToolbarWindow.s_CollabToolbarWindow.initialOpenUrl = "file:///" + EditorApplication.userJavascriptPackagesPath + "unityeditor-collab-toolbar/dist/index.html";
                CollabToolbarWindow.s_CollabToolbarWindow.Init();
                CollabToolbarWindow.s_CollabToolbarWindow.ShowAsDropDown(buttonRect, windowSize);
                CollabToolbarWindow.s_CollabToolbarWindow.OnFocus();
                result = true;
            }
            else
            {
                result = false;
            }
            return(result);
        }
Пример #12
0
        private void Init(Vector2 pos, List <InputData> data, OnSelectCallback callback)
        {
            // Has to be done before calling Show / ShowWithMode
            //pos = GUIUtility.GUIToScreenPoint(pos);


            Rect buttonRect = new Rect(pos.x, pos.y - 16, 16, 16); // fake a button: we know we are showing it below the bottonRect if possible

            buttonRect = GUIUtility.GUIToScreenRect(buttonRect);
            data.Sort(
                delegate(InputData lhs, InputData rhs)
            {
                return(lhs.m_Name.CompareTo(rhs.m_Name));
            });
            m_Data     = data;
            m_Callback = callback;

            if (s_Styles == null)
            {
                s_Styles = new Styles();
            }

            var windowHeight = 2f * kFrameWidth + GetHeight();
            var windowWidth  = 2f * kFrameWidth + GetWidth();
            var windowSize   = new Vector2(windowWidth, windowHeight);

            ShowAsDropDown(buttonRect, windowSize);
        }
Пример #13
0
 void Init(Rect buttonRect, GridPaintPaletteWindow owner)
 {
     m_Owner    = owner;
     m_CellSize = new Vector3(1, 1, 0);
     buttonRect = GUIUtility.GUIToScreenRect(buttonRect);
     ShowAsDropDown(buttonRect, new Vector2(312, 150));
 }
Пример #14
0
        private void Init(Rect buttonRect)
        {
            // Has to be done before calling Show / ShowWithMode
            buttonRect = GUIUtility.GUIToScreenRect(buttonRect);

            CalcValidLayers();

            var rowCount = (s_LayerNames.Count + 2 + 1 + 1);

            var windowHeight = rowCount * EditorGUI.kSingleLineHeight + kSeparatorHeight;

            int sortingLayerCount = InternalEditorUtility.GetSortingLayerCount();

            if (sortingLayerCount > 1)
            {
                windowHeight += kSeparatorHeight + EditorGUI.kSingleLineHeight;
                windowHeight += sortingLayerCount * EditorGUI.kSingleLineHeight;
            }
            m_ContentHeight = windowHeight;
            windowHeight   += 2 * kFrameWidth;
            windowHeight    = Mathf.Min(windowHeight, 600);

            var windowSize = new Vector2(180, windowHeight);

            ShowAsDropDown(buttonRect, windowSize);
        }
        public void OnGUI(Rect connectRect, GUIContent profilerLabel)
        {
            if (!EditorGUI.ButtonMouseDown(connectRect, profilerLabel, FocusType.Native, EditorStyles.toolbarDropDown))
            {
                return;
            }
            List <ProfilerChoise> list = new List <ProfilerChoise>();

            list.Clear();
            AttachProfilerUI.AddPlayerProfilers(list);
            AttachProfilerUI.AddDeviceProfilers(list);
            AttachProfilerUI.AddLastIPProfiler(list);
            this.AddEnterIPProfiler(list, GUIUtility.GUIToScreenRect(connectRect));
            string[] options = (from p in list
                                select p.Name).ToArray <string>();
            bool[] enabled = (from p in list
                              select p.Enabled).ToArray <bool>();
            int num = list.FindIndex((ProfilerChoise p) => p.IsSelected());

            int[] selected;
            if (num == -1)
            {
                selected = new int[0];
            }
            else
            {
                selected = new int[]
                {
                    num
                };
            }
            EditorUtility.DisplayCustomMenu(connectRect, options, enabled, selected, new EditorUtility.SelectMenuItemFunction(this.SelectProfilerClick), list);
        }
Пример #16
0
        public void OnGUI()
        {
            GUIContent content = EditorGUIUtility.TextContent(this.GetConnectedProfiler() + "|Specifies the target player for receiving profiler and log data.");
            Vector2    vector  = EditorStyles.toolbarDropDown.CalcSize(content);
            Rect       rect    = GUILayoutUtility.GetRect(vector.x, vector.y);

            if (EditorGUI.DropdownButton(rect, content, FocusType.Passive, EditorStyles.toolbarDropDown))
            {
                List <ProfilerChoise> list = new List <ProfilerChoise>();
                list.Clear();
                AttachProfilerUI.AddPlayerProfilers(list);
                AttachProfilerUI.AddDeviceProfilers(list);
                AttachProfilerUI.AddLastIPProfiler(list);
                if (!ProfilerDriver.IsConnectionEditor())
                {
                    if (!list.Any((ProfilerChoise p) => p.IsSelected()))
                    {
                        List <ProfilerChoise> arg_10B_0 = list;
                        ProfilerChoise        item      = default(ProfilerChoise);
                        item.Name       = "(Autoconnected Player)";
                        item.Enabled    = false;
                        item.IsSelected = (() => true);
                        item.ConnectTo  = delegate
                        {
                        };
                        arg_10B_0.Add(item);
                    }
                }
                this.AddEnterIPProfiler(list, GUIUtility.GUIToScreenRect(rect));
                this.OnGUIMenu(rect, list);
            }
        }
Пример #17
0
        private void Init(Rect buttonRect)
        {
            buttonRect = GUIUtility.GUIToScreenRect(buttonRect);
            float   y          = 120f;
            Vector2 windowSize = new Vector2(300f, y);

            base.ShowAsDropDown(buttonRect, windowSize);
        }
Пример #18
0
 private void Init(Rect buttonRect)
 {
     buttonRect = GUIUtility.GUIToScreenRect(buttonRect);
     base.ShowAsDropDown(buttonRect, AddCurvesPopup.windowSize, new PopupLocationHelper.PopupLocation[]
     {
         PopupLocationHelper.PopupLocation.Right
     });
 }
Пример #19
0
 private void Init(Rect activatorRect, PopupWindowContent windowContent, PopupLocationHelper.PopupLocation[] locationPriorityOrder)
 {
     this.m_WindowContent = windowContent;
     this.m_WindowContent.editorWindow = this;
     this.m_WindowContent.OnOpen();
     this.m_ActivatorRect = GUIUtility.GUIToScreenRect(activatorRect);
     base.ShowAsDropDown(this.m_ActivatorRect, this.m_WindowContent.GetWindowSize(), locationPriorityOrder);
 }
Пример #20
0
        private void Init(Rect rect)
        {
            var screenRect = GUIUtility.GUIToScreenRect(rect);

            ShowAsDropDown(screenRect, CalculateWindowSize(rect));

            _searchResults.Clear();
            JSScriptFinder.GetInstance().Search(_searchString, _searchType, _searchResults);
        }
Пример #21
0
 private void Init(Rect buttonRect)
 {
     buttonRect = GUIUtility.GUIToScreenRect(buttonRect);
     PopupLocationHelper.PopupLocation[] locationPriorityOrder = new PopupLocationHelper.PopupLocation[] { PopupLocationHelper.PopupLocation.Right };
     base.ShowAsDropDown(buttonRect, this.windowSize, locationPriorityOrder);
     base.Focus();
     base.m_Parent.AddToAuxWindowList();
     base.wantsMouseMove = true;
 }
        void Init(Rect buttonRect)
        {
            s_Hierarchy = new AddCurvesPopupHierarchy();
            s_Hierarchy.InitIfNeeded(this, new Rect(0, 0, k_WindowMinWidth, k_WindowFixedHeight));

            buttonRect = GUIUtility.GUIToScreenRect(buttonRect);

            ShowAsDropDown(buttonRect, GetWindowSize(), new[] { PopupLocation.Right });
        }
Пример #23
0
        protected void DrawColorField()
        {
            GUILayout.BeginVertical();
            GUILayout.Space(4);
            Rect tRect = GUILayoutUtility.GetRect(120, 20, GUILayout.Width(sliderWidth));

            GUI.DrawTexture(tRect, swatch);
            GUILayout.Space(4);
            tRect = GUILayoutUtility.GetRect(150, 20, GUILayout.Width(sliderWidth));
            GUI.DrawTexture(tRect, rainbow);
            hueValue        = GUILayout.HorizontalSlider(hueValue, 0f, 1f, GUILayout.Width(sliderWidth));
            currentHSVColor = new HSBColor(hueValue, currentHSVColor.s, currentHSVColor.b);
            tRect           = GUILayoutUtility.GetRect(colorFieldSize, colorFieldSize, GUILayout.Width(colorFieldSize));
            GUI.DrawTexture(tRect, colorField);

            var eventType = Event.current.type;

            if (eventType == EventType.Repaint)
            {
                if (Input.GetMouseButtonDown(0))
                {
                    Vector2 screenPoint = GUIUtility.GUIToScreenPoint(Event.current.mousePosition);
                    Rect    screenRect  = GUIUtility.GUIToScreenRect(tRect);


                    if (tRect.Contains(Event.current.mousePosition))
                    {
                        int   x       = (int)Mathf.Clamp(Event.current.mousePosition.x - tRect.xMin, 0, sliderWidth);
                        int   y       = colorFieldSize - (int)Mathf.Clamp(Event.current.mousePosition.y - tRect.yMin, 0, sliderWidth);
                        Color sampled = ((Texture2D)colorField).GetPixel(x, y);
                        Utils.Log($"Color picked at {x}, {y} is {sampled}");
                        currentHSVColor = new HSBColor(sampled);
                        currentColor    = new Color(sampled.r, sampled.g, sampled.b, currentColor.a);
                        aValue          = currentColor.a * 255f;
                        rValue          = currentColor.r * 255f;
                        gValue          = currentColor.g * 255f;
                        bValue          = currentColor.b * 255f;

                        aText = aValue.ToString("F0");
                        rText = rValue.ToString("F0");
                        gText = gValue.ToString("F0");
                        bText = bValue.ToString("F0");
                    }
                }
            }

            GUILayout.EndVertical();
            GUILayout.Space(4);



            if (!currentHSVColor.ToColor().Equals(prevHSVColor.ToColor()))
            {
                colorField   = MaterialUtils.GenerateColorField(colorFieldSize, colorFieldSize, currentHSVColor.ToColor());
                prevHSVColor = currentHSVColor;
            }
        }
Пример #24
0
 private void Init(Rect buttonRect)
 {
     buttonRect = GUIUtility.GUIToScreenRect(buttonRect);
     this.CreateComponentTree();
     this.ShowAsDropDown(buttonRect, new Vector2(buttonRect.width, 320f));
     this.Focus();
     this.m_Parent.AddToAuxWindowList();
     this.wantsMouseMove = true;
 }
 private void Init(Rect buttonRect)
 {
     buttonRect = GUIUtility.GUIToScreenRect(buttonRect);
     this.CreateComponentTree();
     base.ShowAsDropDown(buttonRect, new Vector2(buttonRect.width, 320f), null, ShowMode.PopupMenuWithKeyboardFocus);
     base.Focus();
     this.m_Parent.AddToAuxWindowList();
     base.wantsMouseMove = true;
 }
Пример #26
0
 private void Init(Rect rect)
 {
     rect = GUIUtility.GUIToScreenRect(rect);
     this.CreateBehaviourTree();
     base.ShowAsDropDown(rect, new Vector2(rect.width, 320f));
     base.Focus();
     base.m_Parent.AddToAuxWindowList();
     base.wantsMouseMove = true;
 }
        private void DrawSpeechProperties()
        {
            //Voice field
            EditorGUILayout.BeginHorizontal();
            GUILayout.Label("Voice", GUILayout.Width(EditorGUIUtility.labelWidth - 2));
            if (EditorGUILayout.DropdownButton(new GUIContent(string.IsNullOrEmpty(speech.voiceName) ? "None" : speech.voiceName), FocusType.Passive))
            {
                VoicePopup.Show(voiceRect, (Voice voice) =>
                {
                    speech.voiceName = voice.name;
                    speech.voiceUUID = voice.uuid;
                    EditorUtility.SetDirty(speech);
                });
            }

            //Set rect for popup
            if (Event.current.type == EventType.Repaint)
            {
                voiceRect = GUIUtility.GUIToScreenRect(GUILayoutUtility.GetLastRect().Offset(0, 18, 0, 100));
            }
            EditorGUILayout.EndHorizontal();

            //Begin Change Check
            EditorGUI.BeginChangeCheck();

            //Include phonemes
            speech.includePhonemes = EditorGUILayout.Toggle("Include phonemes", speech.includePhonemes);

            //Phoneme table
            if (speech.includePhonemes)
            {
                PhonemeTable temp = EditorGUILayout.ObjectField(phonemeTableLabel, speech.phonemeTable, typeof(PhonemeTable), false) as PhonemeTable;

                //Update phoneme table on clip when change
                if (temp != speech.phonemeTable)
                {
                    speech.phonemeTable = temp;
                    for (int i = 0; i < speech.clips.Count; i++)
                    {
                        if (speech.clips[i].havePhonemes)
                        {
                            speech.clips[i].phonemes.UpdateTable(temp);
                        }
                    }
                }
            }

            //Apply change if any
            if (EditorGUI.EndChangeCheck())
            {
                EditorUtility.SetDirty(speech);
            }

            GUILayout.Space(5);
            Utils.DrawSeparator();
        }
Пример #28
0
 private void Init(Rect activatorRect, PopupWindowContent windowContent, PopupLocationHelper.PopupLocation[] locationPriorityOrder, ShowMode showMode)
 {
     base.hideFlags       = HideFlags.DontSave;
     base.wantsMouseMove  = true;
     this.m_WindowContent = windowContent;
     this.m_WindowContent.editorWindow = this;
     this.m_WindowContent.OnOpen();
     this.m_ActivatorRect = GUIUtility.GUIToScreenRect(activatorRect);
     base.ShowAsDropDown(this.m_ActivatorRect, this.m_WindowContent.GetWindowSize(), locationPriorityOrder, showMode);
 }
 public void Rename()
 {
     StringPopup.Show(GUIUtility.GUIToScreenRect(renameRect.Offset(0, 20, 0, 0)),
                      "Rename clip", clip.clipName, (string value) => {
         if (!string.IsNullOrEmpty(clip.clipName) && value != clip.clipName)
         {
             Rename(value);
         }
     });
 }
Пример #30
0
        public void ShowInputDropdown(InputDropdownArgs args)
        {
            var rect     = GUIUtility.GUIToScreenRect(worldBound);
            var dropdown = new GenericInputDropdown(m_ResourceLoader, PackageManagerWindow.instance, args)
            {
                position = rect
            };

            DropdownContainer.ShowDropdown(dropdown);
        }