Projecting a texture from plane to object

Hey, I’m trying to project a texture from a plane to a wall using raycasts. This should happen in realtime. Since the plane is larger than the wall, only part of the texture is supposed to appear on the front side of the wall. So moving the plane will also change the part of the texture on the wall. The wall can have windows etc so it’s not just a simple cube. I already managed to get the texturecoordinates using raycasts, but I haven’t yet managed to correctly put the texture on the wall. Any ideas how I might achieve this?

I’m pretty sure one way to do is like this:

Write your raycast UV to an open UV channel on your target mesh, and in a custom shader draw that texture with that UV channel.

A better way might be something like the deferred decals example here: Extending Unity 5 rendering pipeline: Command Buffers | Unity Blog