Draw a Texture wherever Raycast hits?

I have a simple scene where a camera can orbit around a sphere gameobject and would like to draw a small cursor texture wherever a raycast shot forward from the camera hits the spheres surface. I’m new to textures in general so i don’t know how to implement it.

See attached image for a better picture.

void DrawCursor()
    {
        RaycastHit hit;
        Ray ray = new Ray (camera.transform.position, camera.transform.forward);

        if (Physics.Raycast (ray, out hit, distance))
        {
            if (hit.collider.tag == "World")
            {
                Debug.DrawRay (camera.transform.position, camera.transform.forward, Color.red);
            }
        }
    }

Hi,

*on 2nd read, i think you didnt mean this… : )

If you want to draw pixels into the texture
Here’s example for that,

It takes textureCoord from raycast hit, then draws with SetPixel().

This example requires that you have some texture already assigned to the material,
and it needs to have [×] read/write enabled in texture importer

You could also generate empty texture at start, and assign that into the material in script.

Thanks! I’ll take a look.