void Awake() { SetCurrentCursor(ref m_CursorA, ref m_CursorB); m_VRMeasureTool = GetComponent <VRMeasureToolController>(); m_PlainLineMaterial = m_Line.material; m_AnchorSelection = new UIAnchorSelection(ref m_MeasureText, ref m_DraggablePad, ref m_Line); UIStateManager.externalToolChanged += OnStateDataChanged; UIStateManager.dragStateChanged += OnDragStateChanged; m_DraggablePad.onBeginDrag.AddListener(OnBeginDrag); m_DraggablePad.onDrag.AddListener(OnDrag); m_DraggablePad.onEndDrag.AddListener(OnEndDrag); m_ResetButton.onClick.AddListener(OnReset); Dispatcher.Dispatch(Payload <ActionTypes> .From(ActionTypes.SetMeasureToolOptions, MeasureToolStateData.defaultData)); }
void Awake() { m_MeasureToolButton.buttonClicked += OnMeasureToolButtonClicked; SetCurrentCursor(m_CursorA, m_CursorB); m_VRMeasureTool = GetComponent <VRMeasureToolController>(); m_ObjectSelector = new SpatialSelector(); m_PlainLineMaterial = m_Line.material; m_PerpendicularModeSprite = m_ModeSwitchImage.sprite; m_ModeSwitchButton = m_ModeSwitchImage.transform.parent.GetComponent <Button>(); m_DisposeOnDestroy.Add(m_MeasureToolStateGetter = UISelectorFactory.createSelector <bool>(MeasureToolContext.current, nameof(IMeasureToolDataProvider.toolState), OnToolStateDataChanged)); m_DisposeOnDestroy.Add(m_ObjectSelectionInfoGetter = UISelectorFactory.createSelector <SelectObjectAction.IObjectSelectionInfo>(ProjectContext.current, nameof(IObjectSelectorDataProvider.objectSelectionInfo))); m_DisposeOnDestroy.Add(UISelectorFactory.createSelector <float>(UIStateContext.current, nameof(IUIStateDisplayProvider <DisplayData> .display) + "." + nameof(IDisplayDataProvider.scaleFactor), OnScaleFactorChanged)); m_DisposeOnDestroy.Add(UISelectorFactory.createSelector <bool>(MeasureToolContext.current, nameof(IMeasureToolDataProvider.toolState), OnToolStateDataChanged)); m_DisposeOnDestroy.Add(UISelectorFactory.createSelector <ToggleMeasureToolAction.MeasureFormat>(MeasureToolContext.current, nameof(IMeasureToolDataProvider.measureFormat), OnMeasureFormatDataChanged)); m_DisposeOnDestroy.Add(m_MeasureModeGetter = UISelectorFactory.createSelector <ToggleMeasureToolAction.MeasureMode>(MeasureToolContext.current, nameof(IMeasureToolDataProvider.measureMode), OnMeasureModeDataChanged)); m_DisposeOnDestroy.Add(UISelectorFactory.createSelector <ToggleMeasureToolAction.AnchorType>(MeasureToolContext.current, nameof(IMeasureToolDataProvider.selectionType), OnSelectionTypeDataChanged)); m_DisposeOnDestroy.Add(UISelectorFactory.createSelector <SelectObjectMeasureToolAction.IAnchor>(MeasureToolContext.current, nameof(IMeasureToolDataProvider.selectedAnchor), OnSelectedAnchorsDataChanged)); m_DisposeOnDestroy.Add(m_VREnableSelector = UISelectorFactory.createSelector <bool>(VRContext.current, nameof(IVREnableDataProvider.VREnable))); m_DisposeOnDestroy.Add(m_VRControllerSelector = UISelectorFactory.createSelector <Transform>(VRContext.current, nameof(IVREnableDataProvider.RightController))); m_AnchorSelection = new UIAnchorSelection(m_MeasureText, m_DraggablePad, m_Line, m_MeasureModeGetter.GetValue, m_VREnableSelector.GetValue, m_VRControllerSelector.GetValue); m_DisposeOnDestroy.Add(m_HashObjectDraggedSelector = UISelectorFactory.createSelector <int>(DragStateContext.current, nameof(IDragStateData.hashObjectDragged))); m_DisposeOnDestroy.Add(UISelectorFactory.createSelector <DragState>(DragStateContext.current, nameof(IDragStateData.dragState), OnDragStateDataChanged)); m_DisposeOnDestroy.Add(UISelectorFactory.createSelector <Vector3>(DragStateContext.current, nameof(IDragStateData.position), OnDragPositionDataChanged)); m_DisposeOnDestroy.Add(m_ActiveToolGetter = UISelectorFactory.createSelector <SetActiveToolAction.ToolType>(ToolStateContext.current, nameof(IToolStateDataProvider.activeTool))); m_DisposeOnDestroy.Add(UISelectorFactory.createSelector <SetHelpModeIDAction.HelpModeEntryID>(UIStateContext.current, nameof(IHelpModeDataProvider.helpModeEntryId), OnHelpModeEntryChanged)); m_DraggablePad.onBeginDrag.AddListener(OnBeginDrag); m_DraggablePad.onDrag.AddListener(OnDrag); m_DraggablePad.onEndDrag.AddListener(OnEndDrag); m_ResetButton.onClick.AddListener(OnReset); m_ModeSwitchButton.onClick.AddListener(OnSwitchMode); }