Prevent GUI texture being rendered after a certain point

I’m currently using the GUI.DrawTexture function to render some stuff. Lets say I have a green texture like the following image.

55755-aaa.png

I’m trying to slide the green square out. I’m currently just using the Lerp function to move the position to the left. So what I am currently doing looks like the square noted as 1.

However, what I want is something like 2. I want to slide the square out, but I don’t want anything to be rendered beyond the black box. I can’t scale the texture since the texture won’t be a simple texture like this example (I will have words or images of a certain object).

I was wondering if anyone knows way to do this. Any help would be appreciated!

ps I’m also rendering the black box using GUI.DrawTexture.

If you are not creating editor script use unity UI system. It’ a matter of seconds to make it in UI using Mask.