Пример #1
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();
        }
Пример #2
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);
            }
        }
Пример #3
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;
            }
        }
Пример #4
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;
        }
Пример #5
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();
        }