public GameObjectRayHit(Ray ray, GameObject hitObject, OrientedBoxRayHit objectBoxHit, MeshRayHit objectMeshHit, TerrainRayHit objectTerrainHit, SpriteRayHit objectSpriteHit)
        {
            _ray       = ray;
            _hitObject = hitObject;

            // Only one kind of entity can be registered as a hit, so we will take the first
            // non-null hit instance using the following priority: terrain, mesh, sprite, box.
            if (objectTerrainHit != null)
            {
                _objectTerrainHit = objectTerrainHit;
                _objectBoxHit     = null;
                _objectMeshHit    = null;
                _objectSpriteHit  = null;
            }
            else
            if (objectMeshHit != null)
            {
                _objectTerrainHit = null;
                _objectBoxHit     = null;
                _objectMeshHit    = objectMeshHit;
                _objectSpriteHit  = null;
            }
            else
            if (objectSpriteHit != null)
            {
                _objectTerrainHit = null;
                _objectBoxHit     = null;
                _objectMeshHit    = null;
                _objectSpriteHit  = objectSpriteHit;
            }
            if (objectBoxHit != null)
            {
                _objectTerrainHit = null;
                _objectBoxHit     = objectBoxHit;
                _objectMeshHit    = null;
                _objectSpriteHit  = 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);
        }