Exemplo n.º 1
0
        // EMPTY
        #region PUBLIC_METHODS
        #endregion


        #region PRIVATE_METHODS
        private void MakeBasicSetup()
        {
            _ListenersDictionary = new Dictionary <string, GameEventListenerTransform>
            {
                { "Right", null },
                { "Left", null },
                { "Gaze", null },
            };

            CheckObject     = CheckSliderClick;
            _uiSetup        = new VRUISetup(CheckObject);
            ClickOnlySetup  = new VRHandleSliderSetup();
            ScrollableSetup = new VRUIScrollableSetup(UnityUIToVRSFUI.SliderDirectionToUIDirection(direction), minValue, maxValue, wholeNumbers);

            // Check if the Listeners GameObject is set correctly. If not, create the child
            if (!ClickOnlySetup.CheckGameEventListenerChild(ref gameEventListenersContainer, ref _ListenersDictionary, transform))
            {
                _uiSetup.CreateGameEventListenerChild(ref gameEventListenersContainer, transform);
            }

            if (!_boxColliderSetup && gameObject.activeInHierarchy)
            {
                StartCoroutine(SetupBoxCollider());
            }

            try
            {
                handleRect = transform.FindDeepChild("Handle").GetComponent <RectTransform>();
                fillRect   = transform.FindDeepChild("Fill").GetComponent <RectTransform>();
            }
            catch
            {
                Debug.LogError("Please add a Handle and a Fill with RectTransform as children of this VR Handle Slider.");
            }
        }
Exemplo n.º 2
0
        // EMPTY
        #region PUBLIC_METHODS
        #endregion


        #region PRIVATE_METHODS
        private void MakeBasicSetup()
        {
            // We initialize the _ListenersDictionary
            _ListenersDictionary = new Dictionary <string, GameEventListenerTransform>
            {
                { "Right", null },
                { "Left", null },
                { "Gaze", null },
            };

            // We create new object to setup the button references; listeners and GameEventListeners
            _CheckObject     = CheckBarClick;
            _uiSetup         = new VRUISetup(_CheckObject);
            _ClickOnlySetup  = new VRScrollbarSetup();
            _ScrollableSetup = new VRUIScrollableSetup(UnityUIToVRSFUI.ScrollbarDirectionToUIDirection(direction));

            // Check if the Listeners GameObject is set correctly. If not, create the child
            if (!_ClickOnlySetup.CheckGameEventListenerChild(ref _GameEventListenersContainer, ref _ListenersDictionary, transform))
            {
                _uiSetup.CreateGameEventListenerChild(ref _GameEventListenersContainer, transform);
            }

            if (!_boxColliderSetup && gameObject.activeInHierarchy)
            {
                StartCoroutine(SetupBoxCollider());
            }

            GetHandleRectReference();
        }
Exemplo n.º 3
0
        private void Init(OnSetupVRReady _)
        {
            if (VRSF_Components.DeviceLoaded != EDevice.SIMULATOR)
            {
                // We setup the references to the ScrollRect elements
                SetScrollRectReferences();

                // We override the directio selected in the inspector by the scrollbar direction if we use one
                // The vertical direction will always have top priority on the horizontal direction
                if (vertical && verticalScrollbar != null)
                {
                    Direction = UnityUIToVRSFUI.ScrollbarDirectionToUIDirection(verticalScrollbar.direction);
                    verticalScrollbar.onValueChanged.AddListener(delegate { OnValueChangedCallback(); });
                }
                else if (horizontal && horizontalScrollbar != null)
                {
                    Direction = UnityUIToVRSFUI.ScrollbarDirectionToUIDirection(horizontalScrollbar.direction);
                    horizontalScrollbar.onValueChanged.AddListener(delegate { OnValueChangedCallback(); });
                }

                ObjectWasClickedEvent.Listeners += CheckRectClick;
                _eventWereRegistered             = true;

                // We setup the Min and Max pos transform
                _scrollableSetup.CheckMinMaxGameObjects(transform, Direction, ref _minPosBar, ref _maxPosBar);
            }
        }
Exemplo n.º 4
0
        private void Init(OnSetupVRReady _)
        {
            if (VRSF_Components.DeviceLoaded != EDevice.SIMULATOR)
            {
                ObjectWasClickedEvent.Listeners += CheckSliderClick;
                ObjectWasHoveredEvent.Listeners += CheckObjectOvered;

                CheckSliderReferences();

                _scrollableSetup = new VRUIScrollableSetup(UnityUIToVRSFUI.SliderDirectionToUIDirection(direction), minValue, maxValue, wholeNumbers);
                _scrollableSetup.CheckMinMaxGameObjects(handleRect.parent, UnityUIToVRSFUI.SliderDirectionToUIDirection(direction), ref _minPosBar, ref _maxPosBar);
            }
        }
Exemplo n.º 5
0
        private void Init(OnSetupVRReady _)
        {
            if (VRSF_Components.DeviceLoaded != EDevice.SIMULATOR)
            {
                GetHandleRectReference();

                // We register the Listener
                ObjectWasClickedEvent.Listeners += CheckBarClick;
                ObjectWasHoveredEvent.Listeners += CheckObjectOvered;

                _scrollableSetup = new VRUIScrollableSetup(UnityUIToVRSFUI.ScrollbarDirectionToUIDirection(direction));
                // Check if the Min and Max object are already created, and set there references
                _scrollableSetup.CheckMinMaxGameObjects(handleRect.parent, UnityUIToVRSFUI.ScrollbarDirectionToUIDirection(direction), ref _minPosBar, ref _maxPosBar);

                value = 1;
            }
        }
Exemplo n.º 6
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;
        }
Exemplo n.º 7
0
        // EMPTY
        #region PUBLIC_METHODS
        #endregion


        #region PRIVATE_METHODS
        private void MakeBasicSetup()
        {
            // We initialize the _ListenersDictionary
            _ListenersDictionary = new Dictionary <string, GameEventListenerTransform>
            {
                { "Right", null },
                { "Left", null },
                { "Gaze", null },
            };

            // We override the directio selected in the inspector by the scrollbar direction if we use one
            // The vertical direction will always have top priority on the horizontal direction
            if (vertical && verticalScrollbar.gameObject != null)
            {
                Direction = UnityUIToVRSFUI.ScrollbarDirectionToUIDirection(verticalScrollbar.direction);
            }
            else if (horizontal && horizontalScrollbar.gameObject != null)
            {
                Direction = UnityUIToVRSFUI.ScrollbarDirectionToUIDirection(horizontalScrollbar.direction);
            }

            // We create new object to setup the button references; listeners and GameEventListeners
            _CheckObject     = CheckRectClick;
            _UISetup         = new VRUISetup(_CheckObject);
            _ClickOnlySetup  = new VRScrollbarSetup();
            _ScrollableSetup = new VRUIScrollableSetup(Direction);

            // Check if the Listeners GameObject is set correctly. If not, create the child
            if (!_ClickOnlySetup.CheckGameEventListenerChild(ref _GameEventListenersContainer, ref _ListenersDictionary, transform))
            {
                _UISetup.CreateGameEventListenerChild(ref _GameEventListenersContainer, transform);
            }

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

            // We setup the references to the ScrollRect elements
            SetScrollRectReferences();
        }
Exemplo n.º 8
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);
        }