private void ClearSelectionAndSelectObject(GameObject gameObject) { ObjectSelection objectSelection = ObjectSelection.Get(); ObjectSelectionUpdateMode selectionUpdateMode = ObjectSelectionSettings.Get().SelectionUpdateMode; if (selectionUpdateMode == ObjectSelectionUpdateMode.EntireHierarchy) { UndoEx.RecordForToolAction(objectSelection); objectSelection.Clear(); objectSelection.AddEntireGameObjectHierarchyToSelection(gameObject); objectSelection.ObjectSelectionGizmos.OnObjectSelectionUpdatedUsingMouseClick(); } else { // Note: We only continue if the picked object is not the only currently selected object. If it is, it means // we would be registering an Undo operation for nothing. if (!ObjectSelection.Get().IsSameAs(gameObject)) { UndoEx.RecordForToolAction(objectSelection); objectSelection.Clear(); objectSelection.AddGameObjectToSelection(gameObject); objectSelection.ObjectSelectionGizmos.OnObjectSelectionUpdatedUsingMouseClick(); } } }
private void ToggleObjectSelectedState(GameObject gameObject) { ObjectSelection objectSelection = ObjectSelection.Get(); ObjectSelectionUpdateMode selectionUpdateMode = ObjectSelectionSettings.Get().SelectionUpdateMode; UndoEx.RecordForToolAction(objectSelection); if (selectionUpdateMode == ObjectSelectionUpdateMode.EntireHierarchy) { if (objectSelection.IsGameObjectSelected(gameObject)) { objectSelection.RemoveEntireGameObjectHierarchyFromSelection(gameObject); } else { objectSelection.AddEntireGameObjectHierarchyToSelection(gameObject); } } else { if (objectSelection.IsGameObjectSelected(gameObject)) { objectSelection.RemoveGameObjectFromSelection(gameObject); } else { objectSelection.AddGameObjectToSelection(gameObject); } } objectSelection.ObjectSelectionGizmos.OnObjectSelectionUpdatedUsingMouseClick(); }
public static void SelectAllObjectsWithSamePrefabAsCurrentSelection() { ObjectSelection objectSelection = ObjectSelection.Get(); List <GameObject> allSelectedObjects = objectSelection.GetAllSelectedGameObjects(); Dictionary <GameObject, GameObject> prefabToObjectMappings = ObjectQueries.GetPrefabToObjectConnectionMappings(allSelectedObjects); List <GameObject> workingObjects = Octave3DWorldBuilder.ActiveInstance.GetAllWorkingObjects(); foreach (GameObject gameObject in workingObjects) { GameObject sourcePrefab = gameObject.GetSourcePrefab(); if (sourcePrefab != null) { if (prefabToObjectMappings.ContainsKey(sourcePrefab)) { objectSelection.AddGameObjectToSelection(gameObject); } } } }