void OnStateDataChanged(ExternalToolStateData externalToolData) { var data = externalToolData.measureToolStateData; if (m_CachedMeasureToolStateData != data) { if (m_CachedMeasureToolStateData == null || m_CachedMeasureToolStateData.Value.toolState != data.toolState) { if (data.toolState) { InitCursor(); m_ResetButton.gameObject.SetActive(true); m_InputActionAsset["MeasureTool/Select"].performed += OnPointerUp; m_InputActionAsset["VR/Select"].performed += OnPointerUp; m_InputActionAsset["MeasureTool/Select"].Enable(); } else { m_ResetButton.gameObject.SetActive(false); m_InputActionAsset["MeasureTool/Select"].performed -= OnPointerUp; m_InputActionAsset["VR/Select"].performed -= OnPointerUp; OnReset(); m_VRMeasureTool.OnReset(); } } if (m_CachedMeasureToolStateData == null || m_CachedMeasureToolStateData.Value.measureFormat != data.measureFormat) { //TODO: reset the current selection } if (m_CachedMeasureToolStateData == null || m_CachedMeasureToolStateData.Value.measureMode != data.measureMode) { //TODO: update the current value of the measure } if (m_CachedMeasureToolStateData == null || m_CachedMeasureToolStateData.Value.selectionType != data.selectionType) { m_AnchorSelection.SetAnchorPickerSelectionType(data.selectionType); if (data.toolState) { OnReset(); } //TODO: update the Cursors style with the current selectionType } if (m_CachedMeasureToolStateData == null || m_CachedMeasureToolStateData.Value.selectedAnchorsContext != data.selectedAnchorsContext) { // Create Point if (m_CreatePointOnScreen) { if (!m_CurrentCursorA.activeSelf) { m_AnchorSelection.OnStateDataChanged(data, m_CurrentCursorA); } else { m_AnchorSelection.OnStateDataChanged(data, m_CurrentCursorB); m_AnchorSelection.SetLineUI(); } m_CreatePointOnScreen = false; return; } // Drag Existing Point m_AnchorSelection.OnStateDataChanged(data); if (m_CurrentCursorB.activeSelf) { m_AnchorSelection.SetLineUI(); } } m_CachedMeasureToolStateData = data; } }
void OnSelectionTypeDataChanged(ToggleMeasureToolAction.AnchorType newData) { m_AnchorSelection?.SetAnchorPickerSelectionType(newData); //TODO: update the Cursors style with the current selectionType }