Exemple #1
0
    private void UpdateRaycast()
    {
        Ray        ray = new Ray(transform.position, transform.forward);
        RaycastHit hit;

        bool bHit = Physics.Raycast(ray, out hit);

        if (_previousTarget && _previousTarget != hit.transform)
        {
            RayPointEventArgs argsOut = new RayPointEventArgs();
            argsOut.distance = 0;
            argsOut.device   = device_;
            argsOut.target   = _previousTarget;
            OnPointOut(argsOut);
            _previousTarget = null;
        }

        if (bHit && _previousTarget != hit.transform)
        {
            RayPointEventArgs argsIn = new RayPointEventArgs();
            argsIn.distance = hit.distance;
            argsIn.device   = device_;
            argsIn.target   = hit.transform;
            OnPointIn(argsIn);
            _previousTarget = hit.transform;
        }

        if (!bHit)
        {
            _previousTarget = null;
        }
    }
Exemple #2
0
 private void OnPointerOut(object sender, RayPointEventArgs e)
 {
     rayPointOut?.Invoke(e);
 }
Exemple #3
0
 private void OnPointerIn(object sender, RayPointEventArgs e)
 {
     rayPointIn?.Invoke(e);
 }
Exemple #4
0
 public void OnPointOut(RayPointEventArgs e)
 {
     pointerOut?.Invoke(this, e);
 }
Exemple #5
0
 public void OnPointIn(RayPointEventArgs e)
 {
     pointerIn?.Invoke(this, e);
 }