Example #1
0
        void Start()
        {
            if (this.IsSharedUpdater(this) && m_Preferences == null)
            {
                m_Preferences = new Preferences();

                // Share one preferences object across all instances
                foreach (var linkedObject in linkedObjects)
                {
                    ((LocomotionTool)linkedObject).m_Preferences = m_Preferences;
                }

                var instance = ObjectUtils.Instantiate(m_RingPrefab, cameraRig, false);
                m_Ring = instance.GetComponent <Ring>();
            }

            m_BlinkVisualsGO          = ObjectUtils.Instantiate(m_BlinkVisualsPrefab, rayOrigin);
            m_BlinkVisuals            = m_BlinkVisualsGO.GetComponentInChildren <BlinkVisuals>();
            m_BlinkVisuals.ignoreList = this.GetVRPlayerObjects();
            m_BlinkVisualsGO.SetActive(false);
            m_BlinkVisualsGO.transform.parent        = rayOrigin;
            m_BlinkVisualsGO.transform.localPosition = Vector3.zero;
            m_BlinkVisualsGO.transform.localRotation = Quaternion.identity;

            var viewerScaleObject = ObjectUtils.Instantiate(m_ViewerScaleVisualsPrefab, cameraRig, false);

            m_ViewerScaleVisuals = viewerScaleObject.GetComponent <ViewerScaleVisuals>();
            viewerScaleObject.SetActive(false);

            InputUtils.GetBindingDictionaryFromActionMap(m_ActionMap, m_Controls);
        }
Example #2
0
        void Start()
        {
            if (this.IsSharedUpdater(this) && m_Preferences == null)
            {
                m_Preferences = new Preferences();

                // Share one preferences object across all instances
                foreach (var linkedObject in linkedObjects)
                {
                    ((SelectionTool)linkedObject).m_Preferences = m_Preferences;
                }
            }

            m_NormalRayColor      = this.GetDefaultRayColor(rayOrigin);
            m_MultiselectRayColor = m_NormalRayColor;
            m_MultiselectRayColor = MaterialUtils.HueShift(m_MultiselectRayColor, k_MultiselectHueShift);

            tooltipTarget = ObjectUtils.CreateEmptyGameObject("SelectionTool Tooltip Target", rayOrigin).transform;
            tooltipTarget.localPosition = this.GetDeviceType() == DeviceType.Oculus ? k_TouchTooltipPosition : k_ViveTooltipPosition;
            tooltipTarget.localRotation = k_TooltipRotation;

            m_BlockSelectCube = ObjectUtils.Instantiate(m_BlockSelectCube, transform);
            m_BlockSelectCube.SetActive(false);
            m_BlockSelectCubeRenderer = m_BlockSelectCube.GetComponent <Renderer>();

            m_BlockSelectSphere = ObjectUtils.Instantiate(m_BlockSelectSphere, transform);
            m_BlockSelectSphere.SetActive(false);

            InputUtils.GetBindingDictionaryFromActionMap(m_ActionMap, m_Controls);
        }
Example #3
0
        void Start()
        {
            if (!this.IsSharedUpdater(this))
            {
                return;
            }

            m_PivotModeToggleAction.execute = TogglePivotMode;
            UpdatePivotModeAction();
            m_PivotRotationToggleAction.execute = TogglePivotRotation;
            UpdatePivotRotationAction();
            m_ManipulatorToggleAction.execute = ToggleManipulator;
            UpdateManipulatorAction();

            // Add standard and scale manipulator prefabs to a list (because you cannot add asset references directly to a serialized list)
            if (m_StandardManipulatorPrefab != null)
            {
                m_StandardManipulator = CreateManipulator(m_StandardManipulatorPrefab);
            }

            if (m_ScaleManipulatorPrefab != null)
            {
                m_ScaleManipulator = CreateManipulator(m_ScaleManipulatorPrefab);
            }

            m_CurrentManipulator = m_StandardManipulator;

            InputUtils.GetBindingDictionaryFromActionMap(m_ActionMap, m_Controls);
        }
Example #4
0
        void Start()
        {
            // Clear selection so we can't manipulate things
            Selection.activeGameObject = null;

            m_ToolMenu = this.InstantiateMenuUI(rayOrigin, m_MenuPrefab);
            var createPrimitiveMenu = m_ToolMenu.GetComponent <CreatePrimitiveMenu>();

            this.ConnectInterfaces(createPrimitiveMenu, rayOrigin);
            createPrimitiveMenu.selectPrimitive = SetSelectedPrimitive;
            createPrimitiveMenu.close           = Close;

            var controls = new BindingDictionary();

            InputUtils.GetBindingDictionaryFromActionMap(standardActionMap, controls);

            foreach (var control in controls)
            {
                foreach (var id in control.Value)
                {
                    var request = this.GetFeedbackRequestObject <ProxyFeedbackRequest>(this);
                    request.node        = node;
                    request.control     = id;
                    request.tooltipText = "Draw";
                    this.AddFeedbackRequest(request);
                }
            }
        }
Example #5
0
        void Start()
        {
            if (this.IsSharedUpdater(this) && m_Preferences == null)
            {
                m_Preferences = new Preferences();

                // Share one preferences object across all instances
                foreach (var linkedObject in linkedObjects)
                {
                    ((LocomotionTool)linkedObject).m_Preferences = m_Preferences;
                }
            }

            m_BlinkVisualsGO          = ObjectUtils.Instantiate(m_BlinkVisualsPrefab, rayOrigin);
            m_BlinkVisuals            = m_BlinkVisualsGO.GetComponentInChildren <BlinkVisuals>();
            m_BlinkVisuals.ignoreList = this.GetVRPlayerObjects();
            m_BlinkVisualsGO.SetActive(false);
            m_BlinkVisualsGO.transform.parent        = rayOrigin;
            m_BlinkVisualsGO.transform.localPosition = Vector3.zero;
            m_BlinkVisualsGO.transform.localRotation = Quaternion.identity;

            m_MainCamera            = CameraUtils.GetMainCamera();
            m_OriginalNearClipPlane = m_MainCamera.nearClipPlane;
            m_OriginalFarClipPlane  = m_MainCamera.farClipPlane;

            Shader.SetGlobalFloat(k_WorldScaleProperty, 1);

            var viewerScaleObject = ObjectUtils.Instantiate(m_ViewerScaleVisualsPrefab, cameraRig, false);

            m_ViewerScaleVisuals = viewerScaleObject.GetComponent <ViewerScaleVisuals>();
            viewerScaleObject.SetActive(false);

            InputUtils.GetBindingDictionaryFromActionMap(m_ActionMap, m_Controls);
        }
        protected override void Awake()
        {
            base.Awake();

            s_LayerMask    = LayerMask.GetMask("UI");
            m_TempRayEvent = new RayEventData(eventSystem);
            InputUtils.GetBindingDictionaryFromActionMap(m_UIActionMap, m_Controls);
        }
Example #7
0
        protected override void Awake()
        {
            base.Awake();
            m_MainCamera = CameraUtils.GetMainCamera();
            m_LayerMask  = LayerMask.GetMask("UI");
            var uiActionMap = MultipleRayInputModuleSettings.instance.UIActionMap;

            InputUtils.GetBindingDictionaryFromActionMap(uiActionMap, m_Controls);
        }
Example #8
0
        void OnEnable()
        {
            m_MainMenuUI = this.InstantiateUI(m_MainMenuPrefab.gameObject).GetComponent <MainMenuUI>();
            m_MainMenuUI.alternateMenuOrigin = alternateMenuOrigin;
            m_MainMenuUI.menuOrigin          = menuOrigin;
            m_MainMenuUI.Setup();

            InputUtils.GetBindingDictionaryFromActionMap(m_ActionMap, m_Controls);
        }
Example #9
0
        void Start()
        {
            m_RadialMenuUI = this.InstantiateUI(m_RadialMenuPrefab.gameObject).GetComponent <RadialMenuUI>();
            m_RadialMenuUI.alternateMenuOrigin = alternateMenuOrigin;
            m_RadialMenuUI.actions             = menuActions;
            this.ConnectInterfaces(m_RadialMenuUI); // Connect interfaces before performing setup on the UI
            m_RadialMenuUI.Setup();
            m_RadialMenuUI.buttonHovered += OnButtonHovered;
            m_RadialMenuUI.buttonClicked += OnButtonClicked;

            InputUtils.GetBindingDictionaryFromActionMap(m_ActionMap, m_Controls);
        }
Example #10
0
 void Start()
 {
     m_UndoMenuUI = this.InstantiateUI(m_UndoMenuPrefab.gameObject).GetComponent <UndoMenuUI>();
     m_UndoMenuUI.alternateMenuOrigin = alternateMenuOrigin;
     this.ConnectInterfaces(m_UndoMenuUI); // Connect interfaces before performing setup on the UI
     m_UndoMenuUI.gameObject.SetActive(false);
     InputUtils.GetBindingDictionaryFromActionMap(m_ActionMap, m_Controls);
     m_TrackpadController = this.GetDeviceType() == DeviceType.Vive;
     m_FeedbackHintForCurrentController = m_TrackpadController
         ? k_FeedbackHintForTrackpadController
         : k_FeedbackHintForJoystickController;
 }
Example #11
0
        void Start()
        {
            // Clear selection so we can't manipulate things
            Selection.activeGameObject = null;

            SetupPreferences();

            m_SmoothInput.Reset(0.0f);

            if (primary)
            {
                this.AddRayVisibilitySettings(rayOrigin, this, false, false);
                SetupBrushUI();
                HandleBrushSize(m_Preferences.brushSize);

                m_ToolMenu = this.InstantiateMenuUI(rayOrigin, m_MenuPrefab);
                var contextMenu = m_ToolMenu.GetComponent <AnnotationContextMenu>();
                this.ConnectInterfaces(contextMenu, rayOrigin);
                contextMenu.close        = Close;
                contextMenu.colorChanged = OnAnnotationColorChanged;
                OnAnnotationColorChanged(m_Preferences.annotationColor);
                contextMenu.preferences   = m_Preferences;
                contextMenu.toolRayOrigin = rayOrigin;

                var controls = new BindingDictionary();
                InputUtils.GetBindingDictionaryFromActionMap(m_ActionMap, controls);

                foreach (var control in controls)
                {
                    var tooltipText      = control.Key;
                    var suppressExisting = control.Key == "Vertical" || control.Key == "StickButton";
                    if (suppressExisting)
                    {
                        tooltipText = null;
                    }

                    foreach (var id in control.Value)
                    {
                        var request = (ProxyFeedbackRequest)this.GetFeedbackRequestObject(typeof(ProxyFeedbackRequest));
                        request.node             = node;
                        request.control          = id;
                        request.priority         = 1;
                        request.tooltipText      = tooltipText;
                        request.suppressExisting = suppressExisting;
                        this.AddFeedbackRequest(request);
                    }
                }
            }
        }
Example #12
0
        public void ProcessInput(WorkspaceInput input, ConsumeControlDelegate consumeControl)
        {
            if (m_Controls.Count == 0)
            {
                InputUtils.GetBindingDictionaryFromActionMap(input.actionMap, m_Controls);
            }

            var moveResizeLeft  = input.moveResizeLeft;
            var moveResizeRight = input.moveResizeRight;

            if (m_DragState != null)
            {
                var rayOrigin = m_DragState.rayOrigin;

                if ((rayOrigin == leftRayOrigin && moveResizeLeft.wasJustReleased) ||
                    (rayOrigin == rightRayOrigin && moveResizeRight.wasJustReleased))
                {
                    m_DragState = null;
                    m_LastResizeIcons.Clear();

                    foreach (var smoothMotion in GetComponentsInChildren <SmoothMotion>())
                    {
                        smoothMotion.enabled = true;
                    }

                    highlightsVisible = false;
                }
                else
                {
                    m_DragState.OnDragging();
                }

                return;
            }

            Transform dragRayOrigin  = null;
            Image     dragResizeIcon = null;
            var       resizing       = false;

            var hasLeft  = false;
            var hasRight = false;

            for (int i = 0; i < m_HovereringRayOrigins.Count; i++)
            {
                var   rayOrigin = m_HovereringRayOrigins[i];
                Image lastResizeIcon;
                m_LastResizeIcons.TryGetValue(rayOrigin, out lastResizeIcon);
                if (rayOrigin == leftRayOrigin)
                {
                    if (m_LeftResizeFeedback.Count == 0)
                    {
                        ShowLeftResizeFeedback();
                    }

                    if (moveResizeLeft.wasJustPressed)
                    {
                        consumeControl(moveResizeLeft);
                        dragRayOrigin  = rayOrigin;
                        dragResizeIcon = lastResizeIcon;
                        resizing       = true;
                    }

                    hasLeft = true;
                }

                if (rayOrigin == rightRayOrigin)
                {
                    if (m_RightResizeFeedback.Count == 0)
                    {
                        ShowRightResizeFeedback();
                    }

                    if (moveResizeRight.wasJustPressed)
                    {
                        consumeControl(moveResizeRight);
                        dragRayOrigin  = rayOrigin;
                        dragResizeIcon = lastResizeIcon;
                        resizing       = true;
                    }

                    hasRight = true;
                }

                const float kVisibleOpacity = 0.75f;
                var         localPosition   = transform.InverseTransformPoint(this.GetPointerPosition(rayOrigin));
                var         direction       = GetResizeDirectionForLocalPosition(localPosition);
                var         resizeIcon      = GetResizeIconForDirection(direction);

                if (lastResizeIcon != null)
                {
                    if (resizeIcon != lastResizeIcon)
                    {
                        resizeIcon.CrossFadeAlpha(kVisibleOpacity, k_ResizeIconCrossfadeDuration, true);
                        lastResizeIcon.CrossFadeAlpha(0f, k_ResizeIconCrossfadeDuration, true);
                    }
                }
                else
                {
                    resizeIcon.CrossFadeAlpha(kVisibleOpacity, k_ResizeIconCrossfadeDuration, true);
                }

                m_LastResizeIcons[rayOrigin] = resizeIcon;

                var iconTransform  = resizeIcon.transform;
                var iconPosition   = iconTransform.localPosition;
                var smoothFollow   = lastResizeIcon == null ? 1 : k_ResizeIconSmoothFollow * Time.deltaTime;
                var localDirection = localPosition - transform.InverseTransformPoint(rayOrigin.position);
                switch (direction)
                {
                case ResizeDirection.Front:
                case ResizeDirection.Back:
                    var iconPositionX   = iconPosition.x;
                    var positionOffsetX = Mathf.Sign(localDirection.x) * m_ResizeHandleMargin;
                    var tergetPositionX = localPosition.x + positionOffsetX;
                    if (Mathf.Abs(tergetPositionX) > bounds.extents.x - m_ResizeCornerSize)
                    {
                        tergetPositionX = localPosition.x - positionOffsetX;
                    }

                    iconPosition.x = Mathf.Lerp(iconPositionX, tergetPositionX, smoothFollow);
                    break;

                case ResizeDirection.Left:
                case ResizeDirection.Right:
                    var iconPositionY   = iconPosition.y;
                    var positionOffsetY = Mathf.Sign(localDirection.z) * m_ResizeHandleMargin;
                    var tergetPositionY = localPosition.z + positionOffsetY;
                    if (Mathf.Abs(tergetPositionY) > bounds.extents.z - m_ResizeCornerSize)
                    {
                        tergetPositionY = localPosition.z - positionOffsetY;
                    }

                    iconPosition.y = Mathf.Lerp(iconPositionY, tergetPositionY, smoothFollow);
                    break;
                }

                iconTransform.localPosition = iconPosition;
            }

            if (!hasRight)
            {
                HideRightResizeFeedback();
            }

            if (!hasLeft)
            {
                HideLeftResizeFeedback();
            }

            var adjustedBounds = this.adjustedBounds;

            if (!dragRayOrigin)
            {
                var leftPosition        = transform.InverseTransformPoint(leftRayOrigin.position);
                var leftPointerPosition = transform.InverseTransformPoint(this.GetPointerPosition(leftRayOrigin));
                if (adjustedBounds.Contains(leftPosition) || adjustedBounds.Contains(leftPointerPosition))
                {
                    if (m_LeftMoveFeedback.Count == 0)
                    {
                        ShowLeftMoveFeedback();
                    }

                    if (moveResizeLeft.wasJustPressed)
                    {
                        dragRayOrigin = leftRayOrigin;
                        m_LastResizeIcons.TryGetValue(dragRayOrigin, out dragResizeIcon);
                        consumeControl(moveResizeLeft);
                    }
                }
                else
                {
                    HideLeftMoveFeedback();
                }

                var rightPosition        = transform.InverseTransformPoint(rightRayOrigin.position);
                var rightPointerPosition = transform.InverseTransformPoint(this.GetPointerPosition(rightRayOrigin));
                if (adjustedBounds.Contains(rightPosition) || adjustedBounds.Contains(rightPointerPosition))
                {
                    if (m_RightMoveFeedback.Count == 0)
                    {
                        ShowRightMoveFeedback();
                    }

                    if (moveResizeRight.wasJustPressed)
                    {
                        dragRayOrigin = rightRayOrigin;
                        m_LastResizeIcons.TryGetValue(dragRayOrigin, out dragResizeIcon);
                        consumeControl(moveResizeRight);
                    }
                }
                else
                {
                    HideRightMoveFeedback();
                }
            }

            if (dragRayOrigin)
            {
                m_DragState = new DragState(this, dragRayOrigin, resizing);
                if (dragResizeIcon != null)
                {
                    dragResizeIcon.CrossFadeAlpha(0f, k_ResizeIconCrossfadeDuration, true);
                }

                ResetFrameThickness();

                foreach (var smoothMotion in GetComponentsInChildren <SmoothMotion>())
                {
                    smoothMotion.enabled = false;
                }

                highlightsVisible = true;
            }
        }
Example #13
0
 void Start()
 {
     InputUtils.GetBindingDictionaryFromActionMap(m_ActionMap, m_Controls);
 }
        public override void ProcessInput(ActionMapInput input, ConsumeControlDelegate consumeControl)
        {
            if (m_Controls.Count == 0)
            {
                InputUtils.GetBindingDictionaryFromActionMap(input.actionMap, m_Controls);
            }

            base.ProcessInput(input, consumeControl);
            var workspaceInput = (WorkspaceInput)input;

            var leftControl    = workspaceInput.miniWorldPanZoomLeft;
            var leftContained  = miniWorld.Contains(leftRayOrigin.position);
            var rightControl   = workspaceInput.miniWorldPanZoomRight;
            var rightContained = miniWorld.Contains(rightRayOrigin.position);

            if (leftContained && !m_LeftRayOriginContained)
            {
                this.Pulse(leftNode, m_EnterExitPulse);
            }
            else if (!leftContained && m_LeftRayOriginContained)
            {
                this.Pulse(leftNode, m_EnterExitPulse);
            }

            if (rightContained && !m_RightRayOriginContained)
            {
                this.Pulse(rightNode, m_EnterExitPulse);
            }
            else if (!rightContained && m_RightRayOriginContained)
            {
                this.Pulse(rightNode, m_EnterExitPulse);
            }

            m_LeftRayOriginContained  = leftContained;
            m_RightRayOriginContained = rightContained;

            if (leftControl.isHeld && rightControl.isHeld)
            {
                ShowSuppressFeedback();
            }
            else
            {
                HideSuppressFeedback();
            }

            if (leftContained)
            {
                if (m_LeftMoveFeedback.Count == 0)
                {
                    ShowLeftMoveFeedback();
                }

                if (rightContained && rightControl.isHeld && m_LeftScaleFeedback.Count == 0)
                {
                    ShowLeftScaleFeedback();
                }

                if (leftControl.wasJustPressed)
                {
                    OnPanZoomDragStarted(leftRayOrigin);
                    consumeControl(leftControl);
                }
            }
            else
            {
                HideLeftMoveFeedback();
            }

            if (rightContained)
            {
                if (m_RightMoveFeedback.Count == 0)
                {
                    ShowRightFeedback();
                }

                if (leftContained && leftControl.isHeld && m_RightScaleFeedback.Count == 0)
                {
                    ShowRightScaleFeedback();
                }

                if (rightControl.wasJustPressed)
                {
                    OnPanZoomDragStarted(rightRayOrigin);
                    consumeControl(rightControl);
                }
            }
            else
            {
                HideRightMoveFeedback();
            }

            if (leftControl.isHeld || rightControl.isHeld)
            {
                OnPanZoomDragging();
            }

            if (leftControl.wasJustReleased)
            {
                OnPanZoomDragEnded(leftRayOrigin);
                HideRightScaleFeedback();
            }

            if (rightControl.wasJustReleased)
            {
                OnPanZoomDragEnded(rightRayOrigin);
                HideLeftScaleFeedback();
            }
        }
Example #15
0
 void Awake()
 {
     setButtonForType      = CreateToolsMenuButton;
     deleteToolsMenuButton = DeleteToolsMenuButton;
     InputUtils.GetBindingDictionaryFromActionMap(m_ActionMap, m_Controls);
 }
        void Start()
        {
            // Clear selection so we can't manipulate things
            Selection.activeGameObject = null;

            SetupPreferences();

            if (primary)
            {
                this.AddRayVisibilitySettings(rayOrigin, this, false, false);
                SetupBrushUI();
                HandleBrushSize(m_Preferences.brushSize);

                m_ColorPickerActivator = this.InstantiateUI(m_ColorPickerActivatorPrefab);
                var otherRayOrigin = otherRayOrigins.First();
                var otherAltMenu   = this.GetCustomAlternateMenuOrigin(otherRayOrigin);

                const float UIOffset = 0.1f;
                var         colorPickerActivatorTransform = m_ColorPickerActivator.transform;
                colorPickerActivatorTransform.SetParent(otherAltMenu);
                colorPickerActivatorTransform.localRotation = Quaternion.identity;
                colorPickerActivatorTransform.localPosition = (node == Node.LeftHand ? Vector3.left : Vector3.right) * UIOffset;
                colorPickerActivatorTransform.localScale    = Vector3.one;

                var activator = m_ColorPickerActivator.GetComponentInChildren <ColorPickerActivator>();

                m_ColorPicker = activator.GetComponentInChildren <ColorPickerUI>(true);
                m_ColorPicker.onHideCalled  = HideColorPicker;
                m_ColorPicker.toolRayOrigin = rayOrigin;
                m_ColorPicker.onColorPicked = OnColorPickerValueChanged;
                OnColorPickerValueChanged(m_Preferences.annotationColor);

                activator.node            = node;
                activator.rayOrigin       = otherRayOrigin;
                activator.showColorPicker = ShowColorPicker;
                activator.hideColorPicker = HideColorPicker;

                var controls = new BindingDictionary();
                InputUtils.GetBindingDictionaryFromActionMap(m_ActionMap, controls);

                foreach (var control in controls)
                {
                    var tooltipText      = control.Key;
                    var suppressExisting = control.Key == "Vertical" || control.Key == "StickButton";
                    if (suppressExisting)
                    {
                        tooltipText = null;
                    }

                    foreach (var id in control.Value)
                    {
                        var request = (ProxyFeedbackRequest)this.GetFeedbackRequestObject(typeof(ProxyFeedbackRequest));
                        request.node             = node;
                        request.control          = id;
                        request.priority         = 1;
                        request.tooltipText      = tooltipText;
                        request.suppressExisting = suppressExisting;
                        this.AddFeedbackRequest(request);
                    }
                }
            }
        }