Example #1
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;
    }
Example #3
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;
        }
    }