/// <summary>
        /// This is basically a constructor. Since ScriptableObjects cannot have constructors,
        /// this one is called from a factory method.
        /// </summary>
        /// <param name="selectionTree">Tree that contains the dropdown items to show.</param>
        /// <param name="windowHeight">Height of the window. If set to 0, it will be auto-adjusted.</param>
        /// <param name="windowPosition">Position of the window to set.</param>
        private void OnCreate(SelectionTree selectionTree, float windowHeight, Vector2 windowPosition, DropdownWindowType windowType)
        {
            ResetControl();
            wantsMouseMove = true;
            _selectionTree = selectionTree;
            _selectionTree.SelectionChanged += Close;
            _optimalWidth           = CalculateOptimalWidth(_selectionTree.SelectionPaths);
            _preventExpandingHeight = new PreventExpandingHeight(windowHeight == 0f);

            _positionOnCreation = GetWindowRect(windowPosition, windowHeight);

            if (windowType == DropdownWindowType.Dropdown)
            {
                // ShowAsDropDown usually shows the window under a button, but since we don't need to align the window to
                // any button, we set buttonRect.height to 0f.
                Rect buttonRect = new Rect(_positionOnCreation)
                {
                    height = 0f
                };
                ShowAsDropDown(buttonRect, _positionOnCreation.size);
            }
            else if (windowType == DropdownWindowType.Popup)
            {
                position = _positionOnCreation;
                ShowPopup();
            }
            else
            {
                throw new Exception("Unknown window type");
            }
        }
        public static DropdownWindow Create(SelectionTree selectionTree, int windowHeight, Vector2 windowPosition, DropdownWindowType windowType)
        {
            var window = CreateInstance <DropdownWindow>();

            window.OnCreate(selectionTree, windowHeight, windowPosition, windowType);
            return(window);
        }