Exemple #1
0
    public void OpenView()
    {
        MenuController.SetMenu("ReviewMenu");
        openSphere = this;

        position = transform.parent.position;
        transform.parent.position = eyeCamera.transform.position;
        transform.parent.up       = Vector3.up;
        beingViewed = true;
        transform.parent.SetParent(eyeCamera.transform);
        transform.localScale = new Vector3(3f, 3f, 3f);

        Camera cam = eyeCamera.GetComponent <Camera>();

        originalCullingMask = cam.cullingMask;
        cam.cullingMask     = (1 << 8) + (1 << 9);
    }
Exemple #2
0
    public void CloseView()
    {
        openSphere = null;

        Camera cam = eyeCamera.GetComponent <Camera>();

        cam.cullingMask = originalCullingMask;

        for (int i = transform.parent.GetChildCount() - 1; i >= 0; i--)
        {
            Transform child = transform.parent.GetChild(i).transform;
            if (child.GetComponent <EmojiButtonBehavior>() != null)
            {
                child.parent = transform;
            }
        }

        transform.parent.SetParent(null);
        beingViewed = false;
        transform.parent.position = position;
        transform.localScale      = new Vector3(0.5f, 0.5f, 0.5f);
    }
    // Update is called once per frame
    void Update()
    {
        RaycastHit hit;
        int        VRUILayerMask = 1 << 8;

        bool didHitReverse;
        bool didHit = Physics.Raycast(
            transform.position,
            transform.rotation * Vector3.up,
            out hit,
            Mathf.Infinity,
            VRUILayerMask,
            QueryTriggerInteraction.Collide
            );

        if (!didHit)
        {
            didHitReverse = ReverseRaycast(out hit);

            if (didHitReverse)
            {
                // print("didHitReverse");
                laser.SetActive(true);
                laser.transform.position   = hit.point;
                laser.transform.up         = hit.point - transform.position;
                laser.transform.localScale = new Vector3(laser.transform.localScale.x, laserLength, laser.transform.localScale.z);
                ReviewSphereBehavior.Draw(hit);
            }

            if (target != null)
            {
                targetUIBehavior.OnExit(null);
                target           = null;
                targetUIBehavior = null;
            }
            if (!didHitReverse)
            {
                laser.SetActive(false);
            }
            return;
        }

        // laser.transform.position = (transform.position + hit.point)/2f;
        laser.SetActive(true);
        laser.transform.position   = hit.point;
        laser.transform.up         = hit.point - transform.position;
        laser.transform.localScale = new Vector3(laser.transform.localScale.x, Mathf.Min(laserLength, hit.distance / 2f), laser.transform.localScale.z);

        if (target != null && target != hit.transform.gameObject)
        {
            targetUIBehavior.OnExit(hit.transform.gameObject);
            target           = null;
            targetUIBehavior = null;
        }

        if (target != null && OVRInput.GetDown(button))
        {
            targetUIBehavior.OnButtonDown(hit);
        }
        else if (target != null && OVRInput.GetUp(button))
        {
            print("OVRInput.GetUp(button)");
            targetUIBehavior.OnButtonUp(hit);
        }
        else if (target != null && OVRInput.Get(button))
        {
            targetUIBehavior.OnDrag(hit);
        }
        else
        {
            if (target == null)
            {
                targetUIBehavior = hit.transform.gameObject.GetComponent(typeof(VRUIBehavior)) as VRUIBehavior;
                if (targetUIBehavior != null)
                {
                    target = hit.transform.gameObject;
                    targetUIBehavior.OnEnter(hit);
                }
            }
            else if (target == hit.transform.gameObject)
            {
                targetUIBehavior.OnMove(hit);
            }
        }
    }