public void GUIDropDownDisplay(params GUILayoutOption[] guiOptions) { InitStyles(); GUIDropDownWindow display = GUIDropDownWindow.Instance; toggleBtnState = GUILayout.Toggle(toggleBtnState, "▼ " + stringOptions[selectedOption] + " ▼", toggleBtnStyle, guiOptions); // Calcuate absolute regions for the button and dropdown list, this only works when // Event.current.type == EventType.Repaint Vector2 relativePos = GUIUtility.GUIToScreenPoint(new Vector2(0, 0)); Rect btnRect = GUILayoutUtility.GetLastRect(); btnRect.x += relativePos.x; btnRect.y += relativePos.y; Rect dropdownRect = new Rect(btnRect.x, btnRect.y + btnRect.height, btnRect.width, 150); if (!isActive && toggleBtnState && Event.current.type == EventType.Repaint) { // User activated the dropdown ShowList(btnRect, dropdownRect); } else if (isActive && (!toggleBtnState || !display.ContainsMouse())) { // User deactivated the downdown or moved the mouse cursor away HideList(); } }
private void Awake() { instance = this; }