void SelectOneUnder(Vector3 screenPos) { var selectableObject = GetComponentUnder(screenPos); if (selectableObject != null) { Select(selectableObject); } OnNewSelection?.Invoke(selectedObjects); }
void SelectAllInBounds() { foreach (T selectableObject in FindObjectsOfType <T>()) { if (IsWithinSelectionBounds(selectableObject.gameObject)) { Select(selectableObject); } } OnNewSelection?.Invoke(selectedObjects); }
/// <summary> /// Object that be focused. /// Invokes event for new or changed selections. /// </summary> /// <param name="newSelection">Focused GameObject</param> public void AddSelection(GameObject newSelection) { m_currentSelection = newSelection; if (m_currentSelection != m_previousSelection) { m_previousSelection = m_currentSelection; OnSelectionChanged?.Invoke(m_currentSelection); } OnNewSelection?.Invoke(newSelection); }