public static bool RaycastBox(this GameObject gameObject, Ray ray, out GameObjectRayHit objectRayHit) { objectRayHit = null; OrientedBox objectWorldOrientedBox = gameObject.GetWorldOrientedBox(); OrientedBoxRayHit objectBoxRayHit; if (objectWorldOrientedBox.Raycast(ray, out objectBoxRayHit)) { objectRayHit = new GameObjectRayHit(ray, gameObject, objectBoxRayHit, null, null, null); } return(objectRayHit != null); }
public static bool RaycastSprite(this GameObject gameObject, Ray ray, out GameObjectRayHit objectRayHit) { objectRayHit = null; SpriteRenderer spriteRenderer = gameObject.GetComponent <SpriteRenderer>(); if (spriteRenderer == null) { return(false); } OrientedBox objectWorldOrientedBox = gameObject.GetWorldOrientedBox(); OrientedBoxRayHit objectBoxRayHit; if (objectWorldOrientedBox.Raycast(ray, out objectBoxRayHit)) { SpriteRayHit spriteHit = new SpriteRayHit(ray, objectBoxRayHit.HitEnter, spriteRenderer, objectBoxRayHit.HitPoint, objectBoxRayHit.HitNormal); objectRayHit = new GameObjectRayHit(ray, gameObject, null, null, null, spriteHit); } return(objectRayHit != null); }