Beispiel #1
0
        private void SetupUIElement()
        {
            _controllersParameter = ControllersParametersVariable.Instance;
            _gazeParameter        = GazeParametersVariable.Instance;

            _interactionContainer = InteractionVariableContainer.Instance;
            _inputContainer       = InputVariableContainer.Instance;

            _rightIsClicking = _inputContainer.RightClickBoolean.Get("TriggerIsDown");
            _leftIsClicking  = _inputContainer.LeftClickBoolean.Get("TriggerIsDown");

            // If the controllers are not used, we cannot click on the slider, so we will fill the slider with the Over events
            if (!_controllersParameter.UseControllers && FillWithClick)
            {
                FillWithClick = false;
                Debug.Log("VRSF : UseController is set at false. The auto fill slider won't use the controller to fill but the gaze.");
            }

            // We initialize the _EventsDictionary
            InitializeEventsDictionaries();

            // We setup the ListenersDictionary
            _clickListenersDictionary = _uiSetup.CheckGameEventListenersPresence(_gameEventListenersContainer, _clickListenersDictionary, 6);
            _overListenersDictionary  = _uiSetup.CheckGameEventListenersPresence(_gameEventListenersContainer, _overListenersDictionary, 6);

            _clickListenersDictionary = _uiSetup.SetGameEventListeners(_clickListenersDictionary, _clickEventsDictionary, _gazeParameter.UseGaze);
            _overListenersDictionary  = _uiSetup.SetGameEventListeners(_overListenersDictionary, _overEventsDictionary, _gazeParameter.UseGaze);
        }
Beispiel #2
0
        private void SetupUIElement()
        {
            _controllersParameter = ControllersParametersVariable.Instance;
            _gazeParameter        = GazeParametersVariable.Instance;

            _interactionContainer = InteractionVariableContainer.Instance;

            // If the controllers are not used, we cannot click on a button
            if (!_controllersParameter.UseControllers)
            {
                Debug.Log("VRSF : You won't be able to use the VR Toggle if you're not using the Controllers. To change that,\n" +
                          "Go into the Window/VRSF/VR Interaction Parameters and set the UseControllers bool to true.");
            }

            // We initialize the _EventsDictionary
            _EventsDictionary = new Dictionary <string, GameEventTransform>
            {
                { "Right", _interactionContainer.RightObjectWasClicked },
                { "Left", _interactionContainer.LeftObjectWasClicked },
                { "Gaze", _interactionContainer.GazeObjectWasClicked },
            };

            // We setup the ListenersDictionary
            _ListenersDictionary = _UISetup.CheckGameEventListenersPresence(_GameEventListenersContainer, _ListenersDictionary);
            _ListenersDictionary = _UISetup.SetGameEventListeners(_ListenersDictionary, _EventsDictionary, _gazeParameter.UseGaze);
        }
Beispiel #3
0
        private void Start()
        {
            _controllersParameter = ControllersParametersVariable.Instance;
            _gazeParameters       = GazeParametersVariable.Instance;
            _interactionContainer = InteractionVariableContainer.Instance;

            if (!_controllersParameter.UseControllers && !_gazeParameters.UseGaze)
            {
                this.enabled = false;
            }
        }
Beispiel #4
0
        /// <summary>
        /// Check every frame if the Ray from a controller/the camera is hitting something
        /// </summary>
        protected override void OnUpdate()
        {
            Entities.ForEach((Entity e, ref VRRaycastParameters parameters, ref VRRaycastOutputs raycastOutputs, ref VRRaycastOrigin origin) =>
            {
                var rayHitSomething = Physics.Raycast(raycastOutputs.RayVar, out raycastOutputs.RaycastHitVar.Value, parameters.MaxRaycastDistance, ~parameters.ExcludedLayer);
                raycastOutputs.RaycastHitVar.IsNull = !rayHitSomething || raycastOutputs.RaycastHitVar.Value.collider == null;

                Vector3 hitPoint     = raycastOutputs.RaycastHitVar.IsNull ? Vector3.zero : raycastOutputs.RaycastHitVar.Value.point;
                GameObject hitObject = raycastOutputs.RaycastHitVar.IsNull ? null : raycastOutputs.RaycastHitVar.Value.collider.gameObject;

                InteractionVariableContainer.SetInteractionVariables(origin.RayOrigin, hitPoint, hitObject);
            });
        }
Beispiel #5
0
        private void Start()
        {
            _controllersParameter = ControllersParametersVariable.Instance;
            _gazeParameter        = GazeParametersVariable.Instance;
            _interactionContainer = InteractionVariableContainer.Instance;

            // We check if the user is at least using the gaze or the controllers
            if (!_controllersParameter.UseControllers && !_gazeParameter.UseGaze)
            {
                this.enabled = false;
            }

            SetupVRComponents();
        }
Beispiel #6
0
        private void Start()
        {
            // Init
            _controllersParameters = ControllersParametersVariable.Instance;
            _gazeParameters        = GazeParametersVariable.Instance;
            _interactionContainer  = InteractionVariableContainer.Instance;

            if (_gazeParameters.UseGaze && _gazeParameters.UseDifferentStates)
            {
                _checkGazeStates = true;
            }

            SetupVRComponents();
        }
Beispiel #7
0
        /// <summary>
        /// Set the GameEvents and GameEventListeners to null
        /// </summary>
        private void InitSOs()
        {
            _controllersParameters = ControllersParametersVariable.Instance;
            _gazeParameters        = GazeParametersVariable.Instance;
            _inputContainer        = InputVariableContainer.Instance;
            _interactionContainer  = InteractionVariableContainer.Instance;

            _geDown      = null;
            _geUp        = null;
            _geTouched   = null;
            _geUntouched = null;

            _gelDown      = null;
            _gelUp        = null;
            _gelTouched   = null;
            _gelUntouched = null;
        }
Beispiel #8
0
        private void SetupUIElement()
        {
            _controllersParameter = ControllersParametersVariable.Instance;
            _gazeParameter        = GazeParametersVariable.Instance;

            _interactionContainer = InteractionVariableContainer.Instance;
            _inputContainer       = InputVariableContainer.Instance;

            _rightTriggerDown = _inputContainer.RightClickBoolean.Get("TriggerIsDown");
            _leftTriggerDown  = _inputContainer.LeftClickBoolean.Get("TriggerIsDown");

            // If the controllers are not used, we cannot click on a Scroll Bar
            if (!_controllersParameter.UseControllers)
            {
                Debug.Log("VRSF : You won't be able to use the VR ScrollBar if you're not using the Controllers. To change that,\n" +
                          "Go into the Window/VRSF/VR Interaction Parameters and set the UseControllers bool to true.");
            }

            // We initialize the _EventsDictionary
            _EventsDictionary = new Dictionary <string, GameEventTransform>
            {
                { "Right", _interactionContainer.RightObjectWasClicked },
                { "Left", _interactionContainer.LeftObjectWasClicked },
                { "Gaze", _interactionContainer.GazeObjectWasClicked },
            };

            // We initialize the RaycastHitDictionary
            _RaycastHitDictionary = new Dictionary <string, RaycastHitVariable>
            {
                { "Right", _interactionContainer.RightHit },
                { "Left", _interactionContainer.LeftHit },
                { "Gaze", _interactionContainer.GazeHit },
            };
            // We setup the ListenersDictionary
            _ListenersDictionary = _uiSetup.CheckGameEventListenersPresence(_GameEventListenersContainer, _ListenersDictionary);
            _ListenersDictionary = _uiSetup.SetGameEventListeners(_ListenersDictionary, _EventsDictionary, _gazeParameter.UseGaze);


            // Check if the Min and Max object are already created, and set there references
            _ScrollableSetup.CheckMinMaxGameObjects(handleRect.parent, UnityUIToVRSFUI.ScrollbarDirectionToUIDirection(direction));
            _ScrollableSetup.SetMinMaxPos(ref _MinPosBar, ref _MaxPosBar, handleRect.parent);

            value = 1;
        }
Beispiel #9
0
        private void SetupUIElement()
        {
            _controllersParameter = ControllersParametersVariable.Instance;
            _gazeParameter        = GazeParametersVariable.Instance;

            _interactionContainer = InteractionVariableContainer.Instance;
            _inputContainer       = InputVariableContainer.Instance;

            _rightIsClicking = _inputContainer.RightClickBoolean.Get("TriggerIsDown");
            _leftIsClicking  = _inputContainer.LeftClickBoolean.Get("TriggerIsDown");

            // If the controllers are not used, we cannot click on the slider, so we will fill the slider with the Over events
            if (!_controllersParameter.UseControllers)
            {
                Debug.Log("VRSF : You won't be able to use the VR Handle Slider if you're not using the Controllers. To change that,\n" +
                          "Go into the Window/VRSF/VR Interaction Parameters and set the UseControllers bool to true.");
            }

            _EventsDictionary = new Dictionary <string, GameEventTransform>
            {
                { "Right", _interactionContainer.RightObjectWasClicked },
                { "Left", _interactionContainer.LeftObjectWasClicked },
                { "Gaze", _interactionContainer.GazeObjectWasClicked },
            };

            _RaycastHitDictionary = new Dictionary <string, RaycastHitVariable>
            {
                { "Right", _interactionContainer.RightHit },
                { "Left", _interactionContainer.LeftHit },
                { "Gaze", _interactionContainer.GazeHit },
            };

            ScrollableSetup.CheckMinMaxGameObjects(handleRect.parent, UnityUIToVRSFUI.SliderDirectionToUIDirection(direction));

            _ListenersDictionary = _uiSetup.CheckGameEventListenersPresence(gameEventListenersContainer, _ListenersDictionary);

            _ListenersDictionary = _uiSetup.SetGameEventListeners(_ListenersDictionary, _EventsDictionary, _gazeParameter.UseGaze);

            ScrollableSetup.SetMinMaxPos(ref _MinPosBar, ref _MaxPosBar, handleRect.parent);
        }
Beispiel #10
0
        // EMPTY
        #region PUBLIC_METHODS
        #endregion PUBLIC_METHODS


        #region PRIVATE_METHODS
        private void SetupUIElement()
        {
            _controllersParameter = ControllersParametersVariable.Instance;
            _gazeParameter        = GazeParametersVariable.Instance;

            _interactionContainer = InteractionVariableContainer.Instance;

            // If the controllers are not used, we cannot click on a Dropdown
            if (!_controllersParameter.UseControllers)
            {
                Debug.Log("VRSF : You won't be able to use the VR DropDown if you're not using the Controllers. To change that,\n" +
                          "Go into the Window/VRSF/VR Interaction Parameters and set the UseControllers bool to true.");
            }

            onValueChanged.AddListener(delegate { SetDropDownNewState(); });

            // We initialize the _EventsDictionary
            _EventsDictionary = new Dictionary <string, GameEventTransform>
            {
                { "Right", _interactionContainer.RightObjectWasClicked },
                { "Left", _interactionContainer.LeftObjectWasClicked },
                { "Gaze", _interactionContainer.GazeObjectWasClicked },
            };

            // We setup the BoxCollider size and center
            if (!_boxColliderSetup && gameObject.activeInHierarchy)
            {
                StartCoroutine(SetupBoxCollider());
            }

            // We setup the ListenersDictionary
            _ListenersDictionary = _UISetup.CheckGameEventListenersPresence(_GameEventListenersContainer, _ListenersDictionary);
            _ListenersDictionary = _UISetup.SetGameEventListeners(_ListenersDictionary, _EventsDictionary, _gazeParameter.UseGaze);

            // We setup the Template and Options to fit the VRFramework
            _Template = transform.Find("Template").gameObject;
            SetToggleReferences();
            ChangeTemplate();
        }
Beispiel #11
0
 protected override void Update()
 {
     base.Update();
     if (Application.isPlaying && _rayHoldingHandle != ERayOrigin.NONE)
     {
         value = _scrollableSetup.SetComponentNewValue(_minPosBar.position, _maxPosBar.position, InteractionVariableContainer.GetCurrentHitPosition(_rayHoldingHandle));
     }
 }
Beispiel #12
0
        private void Update()
        {
            if (Application.isPlaying)
            {
                if (_rayHoldingHandle != ERayOrigin.NONE)
                {
                    if (vertical && verticalScrollbar)
                    {
                        verticalScrollbar.value = CheckScrollbarValue();
                    }
                    else if (horizontal && horizontalScrollbar)
                    {
                        horizontalScrollbar.value = CheckScrollbarValue();
                    }
                }
            }

            float CheckScrollbarValue()
            {
                return(_scrollableSetup.SetComponentNewValue(_minPosBar.position, _maxPosBar.position, InteractionVariableContainer.GetCurrentHitPosition(_rayHoldingHandle)));
            }
        }