void Update()
    {
        WebVRController controller = gameObject.GetComponent <WebVRController>();

        float normalizedTime = controller.GetButton("Trigger") ? 1 : controller.GetAxis("Grip");

        // Use the controller button or axis position to manipulate the playback time for hand model.
        anim.Play("Take", -1, normalizedTime);

        // Raycast from hand
        // Bit shift the index of the layer (8) to get a bit mask
        int layerMask = 1 << 8;

        // This would cast rays only against colliders in layer 8.
        // But instead we want to collide against everything except layer 8. The ~ operator does this, it inverts a bitmask.
        layerMask = ~layerMask;

        RaycastHit hit;
        bool       isHit = Physics.Raycast(transform.position, transform.TransformDirection(Vector3.forward), out hit, Mathf.Infinity, layerMask);

        if (isHit)
        {
            cursor.transform.localScale    = new Vector3(cursor.transform.localScale.x, cursor.transform.localScale.y, hit.distance);
            cursor.transform.localPosition = new Vector3(cursor.transform.localPosition.x, cursor.transform.localPosition.y, hit.distance / 2);
            cursorRend.material.color      = cursorOverColor;
        }
        else
        {
            cursor.transform.localScale    = new Vector3(cursor.transform.localScale.x, cursor.transform.localScale.y, cursorDrawDistance);
            cursor.transform.localPosition = new Vector3(cursor.transform.localPosition.x, cursor.transform.localPosition.y, cursorDrawDistance / 2);
            cursorRend.material.color      = cursorColor;
        }

        if (controller.GetButtonDown("Trigger") || controller.GetButtonDown("Grip"))
        {
        }

        if (controller.GetButtonUp("Trigger") || controller.GetButtonUp("Grip"))
        {
            if (isHit)
            {
                string image = hit.collider.gameObject.GetComponent <PanoIcon>().Image;
                RenderSettings.skybox = Resources.Load(image, typeof(Material)) as Material;
            }
        }
    }
Ejemplo n.º 2
0
    void Update()
    {
        WebVRController controller = gameObject.GetComponent <WebVRController>();

        float normalizedTime = controller.GetButton("Trigger") ? 1 : controller.GetAxis("Grip");

        if (controller.GetButtonDown("Trigger") || controller.GetButtonDown("Grip"))
        {
            Pickup();
        }

        if (controller.GetButtonUp("Trigger") || controller.GetButtonUp("Grip"))
        {
            Drop();
        }

        // Use the controller button or axis position to manipulate the playback time for hand model.
        anim.Play("Take", -1, normalizedTime);
    }
Ejemplo n.º 3
0
 void Start()
 {
     anim       = gameObject.GetComponent <Animator>();
     controller = gameObject.GetComponent <WebVRController>();
 }
Ejemplo n.º 4
0
 public static WebVRController Other(WebVRController c)
 {
     return(c.hand == WebVRControllerHand.LEFT ? Right : Left);
 }
Ejemplo n.º 5
0
 private void Start()
 {
     controller = gameObject.GetComponent <WebVRController>();
 }