Exemplo n.º 1
0
    // Update is called once per frame
    void Update()
    {
        if (m_hand.CurrentHand == null)
        {
            Asterisms.AsterismDrawer.DisableAllAsterisms();
            return;
        }

        //Asterisms.AsterismDrawer.DisableAllAsterisms();
        if (m_gripToggle.enabled && WidgetShowcase.ModalityManager.Instance.CanActivate(gameObject))
        {
            Vector2 screenPoint = m_leftCam.WorldToScreenPoint(m_hand.CurrentHand.GetPalmPosition());
            Ray     throughHand = m_leftCam.ScreenPointToRay(screenPoint);

            //Debug.DrawRay(m_leftCam.transform.position, m_leftCam.ScreenPointToRay(screenPoint).direction * 1000.0f);

            RaycastHit castInfo;
            bool       hit = Physics.Raycast(throughHand, out castInfo, float.PositiveInfinity, LayerMask.GetMask("AsterismColliders"));

            if (hit)
            {
                AsterismReference asterismRef = castInfo.transform.GetComponent <AsterismReference>();
                if (asterismRef != null)
                {
                    Asterisms.AsterismParser.AsterismData[asterismRef.index].IsSelected = true;
                }
            }
        }
    }
Exemplo n.º 2
0
    // Identify pulled object using view of hand
    void Update()
    {
        if (view == null)
        {
            return;
        }

        if (m_hand.CurrentHand == null)
        {
            if (pulled != null)
            {
                if (!attemptingToReaquire)
                {
                    StartCoroutine(reaquireHand(2.0f));
                }
            }
            return;
        }

        if (pulled != null)
        {
            return;
        }



        if (Hold == null && m_hand.CurrentHand != null)
        {
            updateHold();
            //GrabberHand grabberHand = m_hand.CurrentHand.gameObject.GetComponent<GrabberHand>();
            //if ( grabberHand == null ) { return; }
            //Hold = grabberHand.hold;
        }


        Vector2 screenPoint = m_leftCam.WorldToScreenPoint(m_hand.CurrentHand.GetPalmPosition());
        Ray     throughHand = m_leftCam.ScreenPointToRay(screenPoint);

        //Debug.DrawRay(m_leftCam.transform.position, m_leftCam.ScreenPointToRay(screenPoint).direction * 1000.0f);

        RaycastHit castInfo;
        bool       hit = Physics.Raycast(throughHand, out castInfo, float.PositiveInfinity, LayerMask.GetMask("AsterismColliders"));

        if (hit)
        {
            if (!Activate())
            {
                this.enabled = false;
                return;
            }

            AsterismReference asterismRef = castInfo.transform.GetComponent <AsterismReference>();
            if (asterismRef != null)
            {
                Asterisms.Asterism hitAsterism = asterismRef.Asterism;

                PullToHold intersect = hitAsterism.mover.GetComponent <PullToHold>();

                if (intersect.cameraPoint == null)
                {
                    intersect.cameraPoint = m_leftCam.transform;
                }

                if (intersect != null)
                {
                    SelectStars(hitAsterism.mover);
                    Acquire(intersect);
                }
            }
        }
    }