private static Bounds GetBoundsOfSelection(SketchObjectSelection selection) { Bounds selectionBounds = new Bounds(); MeshRenderer[] renderers = selection.gameObject.GetComponentsInChildren <MeshRenderer>(); foreach (MeshRenderer renderer in renderers) { selectionBounds.Encapsulate(renderer.bounds); } return(selectionBounds); }
/// <summary> /// Reverts the high light of all selected objects and resets the active selection. /// </summary> internal void Deactivate() { if (ActiveSketchObjectSelection == this) { ActiveSketchObjectSelection = null; } gameObject.BroadcastMessage(nameof(IHighlightable.revertHighlight)); boundsVisualizationObject.SetActive(false); foreach (SelectableObject selected in SketchObjectsOfSelection) { selected.resetToParentGroup(); } }
/// <summary> /// Highlight all objects added to this selection and set this selection as active selection. /// </summary> internal void Activate() { if (ActiveSketchObjectSelection != this) { if (ActiveSketchObjectSelection != null) { ActiveSketchObjectSelection.Deactivate(); } ActiveSketchObjectSelection = this; } foreach (SelectableObject selected in SketchObjectsOfSelection) { selected.transform.SetParent(this.transform); } SetUpBoundingBoxVisualization(GetBoundsOfSelection(this)); boundsVisualizationObject.SetActive(true); this.gameObject.BroadcastMessage(nameof(IHighlightable.highlight)); }