Пример #1
0
    void addEventTriggers()
    {
        GvrPointerInputModule globalInputModule = (GvrPointerInputModule)FindObjectOfType(typeof(GvrPointerInputModule));

        globalInputModule.EventExecutor.OnPointerDown += startRewind;
        globalInputModule.EventExecutor.OnPointerUp   += stopRewind;
    }
Пример #2
0
 private void Start()
 {
     this.inputModule = GvrPointerInputModule.FindInputModule();
     if (!this.inputModule)
     {
         Debug.Log("Cannot find GvrPointerInputModule in scene on Start!");
     }
 }
    // Update is called once per frame
    void Update()
    {
        rp = GvrPointerInputModule.FindInputModule().Impl.Pointer as GvrReticlePointer;
        RectTransform rt  = GetComponent <RectTransform>();
        Vector3       pos = new Vector3(rt.localPosition.x, rt.localPosition.y,
                                        rp.ReticleDistanceInMeters);

        rt.anchoredPosition3D = pos;
    }
Пример #4
0
 public void OnPointerEnter(BaseEventData data) {
   inp = data.currentInputModule as GvrPointerInputModule;
   if (inp != null && inp.transform.position != Vector3.zero) {
     newPositionHandle.transform.position = new Vector3(
         inp.transform.position.x,
         newPositionHandle.transform.position.y,
         newPositionHandle.transform.position.z);
   }
   newPositionHandle.SetActive(true);
 }
Пример #5
0
    /// Helper function to find the Event Executor that is part of
    /// the input module if one exists in the scene.
    public static GvrEventExecutor FindEventExecutor()
    {
        GvrPointerInputModule gvrInputModule = FindInputModule();

        if (gvrInputModule == null)
        {
            return(null);
        }

        return(gvrInputModule.EventExecutor);
    }
        private void RemoveListeners()
        {
            GvrEventExecutor executor = GvrPointerInputModule.FindEventExecutor();

            if (executor == null)
            {
                return;
            }

            executor.OnPointerClick -= OnPointerClick;
        }
Пример #7
0
 public void OnPointerEnter(BaseEventData data)
 {
     inp = data.currentInputModule as GvrPointerInputModule;
     if (inp != null && inp.transform.position != Vector3.zero)
     {
         newPositionHandle.transform.position = new Vector3(
             inp.transform.position.x,
             newPositionHandle.transform.position.y,
             newPositionHandle.transform.position.z);
     }
     newPositionHandle.SetActive(true);
 }
Пример #8
0
    public static bool IsPointerOverUIObject()
    {
        if (_GvrInputModule == null)
        {
            _GvrInputModule = FindObjectOfType <GvrPointerInputModule>();
        }

        if (_GvrInputModule == null)
        {
            return(false);
        }

        return(_GvrInputModule.Impl.CurrentEventData != null && _GvrInputModule.Impl.CurrentEventData.pointerEnter != null);
    }
Пример #9
0
    /// GvrBasePointer calls this when it is created.
    /// If a pointer hasn't already been assigned, it
    /// will assign the newly created one by default.
    ///
    /// This simplifies the common case of having only one
    /// GvrBasePointer so is can be automatically hooked up
    /// to the manager.  If multiple GvrBasePointers are in
    /// the scene, the app has to take responsibility for
    /// setting which one is active.
    public static void OnPointerCreated(GvrBasePointer createdPointer)
    {
        GvrPointerInputModule module = FindInputModule();

        if (module == null || module.Impl == null)
        {
            return;
        }

        if (module.Impl.Pointer == null)
        {
            module.Impl.Pointer = createdPointer;
        }
    }
Пример #10
0
    private void AddListeners()
    {
        GvrEventExecutor eventExecutor = GvrPointerInputModule.FindEventExecutor();

        if (eventExecutor == null)
        {
            return;
        }

        eventExecutor.OnPointerClick += OnPointerClickHandler;
        eventExecutor.OnPointerDown  += OnPointerDownHandler;
        eventExecutor.OnPointerUp    += OnPointerUpHandler;
        eventExecutor.OnPointerEnter += OnPointerEnterHandler;
        eventExecutor.OnPointerExit  += OnPointerExitHandler;
    }
Пример #11
0
    private void RemoveListeners()
    {
        GvrEventExecutor eventExecutor = GvrPointerInputModule.FindEventExecutor();

        if (eventExecutor == null)
        {
            return;
        }

        eventExecutor.OnPointerClick -= OnPointerClickHandler;
        eventExecutor.OnPointerDown  -= OnPointerDownHandler;
        eventExecutor.OnPointerUp    -= OnPointerUpHandler;
        eventExecutor.OnPointerEnter -= OnPointerEnterHandler;
        eventExecutor.OnPointerExit  -= OnPointerExitHandler;
    }
    /// Helper function to find the input module if one exists in the
    /// scene and it is the active module.
    public static GvrPointerInputModule FindInputModule()
    {
        if (EventSystem.current == null)
        {
            return(null);
        }

        BaseInputModule inputModule = EventSystem.current.currentInputModule;

        if (inputModule == null)
        {
            return(null);
        }

        GvrPointerInputModule gvrInputModule = inputModule as GvrPointerInputModule;

        return(gvrInputModule);
    }
Пример #13
0
    /// Helper function to find the input module if one exists in the
    /// scene and it is the active module.
    public static GvrPointerInputModule FindInputModule()
    {
        if (EventSystem.current == null)
        {
            return(null);
        }

        EventSystem eventSystem = EventSystem.current;

        if (eventSystem == null)
        {
            return(null);
        }

        GvrPointerInputModule gvrInputModule =
            eventSystem.GetComponent <GvrPointerInputModule>();

        return(gvrInputModule);
    }
Пример #14
0
    private void Awake()
    {
        vrMenuController       = vrControls.GetComponent <MenuController>();
        portraitMenuController = portraitControls.GetComponent <MenuController>();
        startMenu        = GetComponentInChildren <StartMenu>();
        menuPivot        = vrControls.transform.parent;
        cameraTrans      = GetComponentInChildren <Camera>().gameObject.transform;
        vrInputModule    = eventSystem.GetComponent <GvrPointerInputModule>();
        touchInputModule = eventSystem.GetComponent <StandaloneInputModule>();

        if (deviceName != "Oculus")
        {
            StartCoroutine(ChangeToPortrait());
        }
        else
        {
            StartCoroutine(ChangeToVr());
        }
    }
Пример #15
0
    private void GvrReticlePointer_OnPointerEnterEvent(RaycastResult raycastResult)
    {
        raycastResultObj = null;
        mEnterTime       = Time.time;
        MaterialComp.SetFloat("_FillAmount", 0);
        manger = 0;
        //EventExcuted = false;
        EventExcuteCount = 0;
        GvrPointerInputModule module = EventSystem.current.currentInputModule as GvrPointerInputModule;
        GameObject            click  = module.EventExecutor.GetEventHandler <IPointerClickHandler>(raycastResult.gameObject);

        if (click)
        {
            bool       canOperation = false;
            Selectable selectable   = click.GetComponent <Selectable>();
            if (selectable != null)
            {
                if (selectable.interactable)
                {
                    canOperation = true;
                }
            }
            else
            {
                canOperation = true;
            }
            if (canOperation)
            {
                raycastResultObj = click;
                UICountDown mUICountDown = click.GetComponent <UICountDown>();
                if (mUICountDown != null)
                {
                    mTargetTime  = mUICountDown.Count;
                    mIsContitnue = mUICountDown.Continue;
                }
                else
                {
                    mTargetTime = DEFALUTCOUNT;
                }
            }
        }
    }
Пример #16
0
    void Start()
    {
        _trigger = GetComponent <EventTrigger>();
        EventTrigger.Entry entry = new EventTrigger.Entry();
        entry.eventID = EventTriggerType.PointerDown;
        entry.callback.AddListener((data) => OnClick());
        _trigger.triggers.Add(entry);



        EventTrigger.Entry entry2 = new EventTrigger.Entry();
        entry2.eventID = EventTriggerType.PointerUp;
        entry2.callback.AddListener((data) => OnExit());
        _trigger.triggers.Add(entry2);


        rb = GetComponent <Rigidbody>();
        GvrEventExecutor eventExecutor = GvrPointerInputModule.FindEventExecutor();

        eventExecutor.OnPointerClick += OnItemInterract;
    }
        // -------------------------------------------

        /*
         * Getting the reference of the input controllers
         */
        public void Initialitzation()
        {
            if (m_hasBeenInitialized)
            {
                return;
            }
            m_hasBeenInitialized = true;

            m_standAloneInputModule = this.gameObject.GetComponent <StandaloneInputModule>();
            if (m_standAloneInputModule == null)
            {
                this.gameObject.AddComponent <StandaloneInputModule>();
                m_standAloneInputModule = this.gameObject.GetComponent <StandaloneInputModule>();
            }
#if !ENABLE_OCULUS && !ENABLE_HTCVIVE && !ENABLE_PICONEO && UNITY_HAS_GOOGLEVR && ENABLE_PARTY_2018
            m_gazeInputModule = this.gameObject.GetComponent <GvrPointerInputModule>();
            if (m_gazeInputModule == null)
            {
                Debug.LogError("WARNNING: The project can work in a non-VR related project, but it's meant to run mainly for VR projects");
            }
#endif

            UIEventController.Instance.UIEvent += new UIEventHandler(OnBasicEvent);
        }
Пример #18
0
    // Update is called once per frame
    void Update()
    {
        if (!this.inputModule)
        {
            this.inputModule = GvrPointerInputModule.FindInputModule();
            if (!unfoundInputModule && !this.inputModule)
            {
                Debug.LogError("Must have a GvrPointerInputModule in scene for GVR usage!");
                this.unfoundInputModule = true;
            }
            else if (this.inputModule)
            {
                Debug.Log("Found a GvrPointerInputModule on Update.");
            }
        }

        if (BlockedInput())
        {
            this.blocked = true;
        }

        ProcessInput();

        // Set downtime
        if (pressedDown)
        {
            this.downTime += Time.deltaTime;

            if (firstFrame)
            {
                this.firstFrameTime = this.downTime;
            }
            else
            {
                this.firstFrameTime = -1;
            }
        }

        // Processed inputs
        if (!blocked)
        {
            if (pressedDown)
            {
                if (!this.held && this.downTime > 0 && this.downTime > this.tapDuration)
                {
                    if (onHoldDown != null)
                    {
                        onHoldDown();
                    }
                }
            }
            else if ((this.downTime > 0 && this.downTime <= this.tapDuration) || this.firstFrameTime == this.downTime)
            {
                if (onTap != null)
                {
                    onTap();
                }
            }
            else if (this.downTime > 0 && this.downTime > this.tapDuration)
            {
                if (onHoldUp != null)
                {
                    onHoldUp();
                }
            }
        }

        if (!pressedDown)
        {
            blocked = false;
        }

        // Raw inputs
        if (pressedDown)
        {
            if (!this.held && this.downTime > 0 && this.downTime > this.tapDuration)
            {
                if (onHoldDownRaw != null)
                {
                    onHoldDownRaw();
                }
                this.held = true;
            }
        }
        else if ((this.downTime > 0 && this.downTime <= this.tapDuration) || this.firstFrameTime == this.downTime)
        {
            if (onTapRaw != null)
            {
                onTapRaw();
            }
            this.downTime       = 0;
            this.firstFrameTime = -1;
        }
        else if (this.downTime > 0 && this.downTime > this.tapDuration)
        {
            if (onHoldUpRaw != null)
            {
                onHoldUpRaw();
            }
            this.downTime = 0;
            this.held     = false;
        }
    }
Пример #19
0
 public void OnPointerExit(BaseEventData data) {
   inp = null;
   newPositionHandle.SetActive(false);
 }
Пример #20
0
 /// @cond
 /// <summary>
 /// This MonoBehavior's Start() implementation.
 /// </summary>
 protected virtual void Start()
 {
     GvrPointerInputModule.OnPointerCreated(this);
 }
Пример #21
0
 public void OnPointerExit(BaseEventData data)
 {
     inp = null;
     newPositionHandle.SetActive(false);
 }
Пример #22
0
 public static void OnPointerCreated(GvrBasePointer createdPointer)
 {
     GvrPointerInputModule.OnPointerCreated(createdPointer);
 }