Cursor.CalculateRayIntersect C# (CSharp) Méthode

CalculateRayIntersect() protected méthode

protected CalculateRayIntersect ( ) : RaycastResult
Résultat RaycastResult
    protected override RaycastResult CalculateRayIntersect()
    {
        RaycastResult result;

        // Check UI elements - they get precedence
        Vector3 hitPos, hitNormal;
        Button hitButton;
        if (RayCastUI(out hitPos, out hitNormal, out hitButton))
        {
            result.Hit = true;
            result.Position = hitPos;
            result.Normal = hitNormal;

            return result;
        }

        // Now use the understanding code
        if (SpatialUnderstanding.Instance.AllowSpatialUnderstanding &&
            (SpatialUnderstanding.Instance.ScanState == SpatialUnderstanding.ScanStates.Done))
        {
            Vector3 rayPos = Camera.main.transform.position;
            Vector3 rayVec = Camera.main.transform.forward * RayCastLength;
            IntPtr raycastResultPtr = SpatialUnderstanding.Instance.UnderstandingDLL.GetStaticRaycastResultPtr();
            SpatialUnderstandingDll.Imports.PlayspaceRaycast(
                rayPos.x, rayPos.y, rayPos.z, rayVec.x, rayVec.y, rayVec.z,
                raycastResultPtr);
            rayCastResult = SpatialUnderstanding.Instance.UnderstandingDLL.GetStaticRaycastResult();

            // Override
            if (rayCastResult.SurfaceType != SpatialUnderstandingDll.Imports.RaycastResult.SurfaceTypes.Invalid)
            {
                result.Hit = true;
                result.Position = rayCastResult.IntersectPoint;
                result.Normal = rayCastResult.IntersectNormal;

                return result;
            }
        }

        // Base
        return base.CalculateRayIntersect();
    }