public void Init(Rect buttonRect) { Vector2 screenPoint = GUIUtility.GUIToScreenPoint(new Vector2(buttonRect.x, buttonRect.y)); buttonRectScreenPos.x = screenPoint.x; buttonRectScreenPos.y = screenPoint.y; if (state == null) { state = new AdvancedDropdownState(); } if (dataSource == null) { dataSource = new MultiLevelDataSource(); } if (gui == null) { gui = new AdvancedDropdownGUI(); } gui.State = state; gui.Init(); // Has to be done before calling Show / ShowWithMode screenPoint = GUIUtility.GUIToScreenPoint(new Vector2(buttonRect.x, buttonRect.y)); buttonRect.x = screenPoint.x; buttonRect.y = screenPoint.y; Vector2 requiredDropdownSize; OnDirtyList(); currentlyRenderedTree = HasSearch ? dataSource.SearchTree : dataSource.MainTree; ShowAsDropDown(buttonRect, CalculateWindowSize(buttonRectScreenPos, out requiredDropdownSize)); // If the dropdown is as height as the screen height, give it some margin if (position.height < requiredDropdownSize.y) { Rect pos = position; pos.y += 5; pos.height -= 10; position = pos; } if (SetInitialSelectionPosition) { initialSelectionPosition = gui.GetSelectionHeight(dataSource, buttonRect); } wantsMouseMove = true; SetSelectionFromState(); }
public AdvancedDropdown(AdvancedDropdownState state) { this.state = state; }