public RectSelector(GUISystem guiSystem) { m_GUISystem = guiSystem; m_RectSelectorControl = new GenericDefaultControl("RectSelector") { position = (guiState) => { return(GUIToWorld(guiState, guiState.mousePosition)); }, forward = (guiState) => { if (Camera.current) { return(Camera.current.transform.forward); } return(Vector3.forward); }, right = (guiState) => { if (Camera.current) { return(Camera.current.transform.right); } return(Vector3.right); }, up = (guiState) => { if (Camera.current) { return(Camera.current.transform.up); } return(Vector3.up); } }; m_RectSelectAction = new SliderAction(m_RectSelectorControl) { enableRepaint = (guiState, action) => { var size = m_RectStart - m_RectEnd; return(size != Vector3.zero && guiState.hotControl == action.ID); }, onClick = (guiState, control) => { m_RectStart = GUIToWorld(guiState, guiState.mousePosition); m_RectEnd = m_RectStart; m_GUIRect = CalculateGUIRect(); }, onSliderBegin = (guiState, control, position) => { m_RectEnd = position; m_GUIRect = CalculateGUIRect(); if (onSelectionBegin != null) { onSelectionBegin(this, guiState.isShiftDown); } }, onSliderChanged = (guiState, control, position) => { m_RectEnd = position; m_GUIRect = CalculateGUIRect(); if (onSelectionChanged != null) { onSelectionChanged(this); } }, onSliderEnd = (guiState, control, position) => { if (onSelectionEnd != null) { onSelectionEnd(this); } }, onRepaint = (guiState, action) => { m_Drawer.DrawSelectionRect(m_GUIRect); } }; m_GUISystem.AddControl(m_RectSelectorControl); m_GUISystem.AddAction(m_RectSelectAction); }