コード例 #1
0
        public static int SampleSurface(Transform transform, SurfaceEffectsData data, out Vector3 hitPoint)
        {
            hitPoint = Vector3.zero;
            int result = -1;

            if (Physics.Raycast(transform.position + Vector3.up * 0.9f, Vector3.down, out var hitInfo, 2f, LayerConstants.GetSurfaceSamplerLayerCollisionMask()))
            {
                hitPoint = hitInfo.point;
                result   = GetSurfaceType(ref hitInfo, data);
            }
            return(result);
        }
コード例 #2
0
        public static int GetSurfaceType(ref RaycastHit hit, SurfaceEffectsData data)
        {
            int result = -1;

            if (hit.collider != null)
            {
                int num = 1 << hit.collider.gameObject.layer;
                for (int i = 0; i < data.Effects.Length; i++)
                {
                    if (num == data.Effects[i].SurfaceLayer.value)
                    {
                        result = i;
                        break;
                    }
                    if (!string.IsNullOrEmpty(data.Effects[i].SurfaceTag) && hit.collider.CompareTag(data.Effects[i].SurfaceTag))
                    {
                        result = i;
                        break;
                    }
                }
            }
            return(result);
        }