示例#1
0
    private void UpdateLine()
    {
        //use default value from our input module or distance
        PointerEventData data         = m_InputModule.GetData();
        float            TargetLength = data.pointerCurrentRaycast.distance == 0 ? m_DefaultLength : data.pointerCurrentRaycast.distance;

        //Raycast
        hitedRay = CreateRaycast(TargetLength);

        //Default
        EndPosition = transform.position + (transform.forward * TargetLength);

        //Update when hitting something (Check for collider)
        if (hitedRay.collider != null)
        {
            EndPosition = hitedRay.point;
        }

        //Set position of the Dot
        m_Dot.transform.position = EndPosition;

        //Set position of LineRenderer
        m_LineRenderer.SetPosition(0, transform.position);
        m_LineRenderer.SetPosition(1, EndPosition);
    }