How to change color of sprite as it moves over different backgrounds


I have a rectangle sprite which moves slides across two backgrounds, white and black, as shown in the image below. I would like to change the part of the rectangle sprite to opposite color when its on a particular background.

Example: when half of the sprite is on black background and other half on white, then the part which is on black background should change its color to white and the vice versa for the other side.

You will better understand my question with the images below.

Main Screen

Slided Screen

Sprite Masks might be of use here. Unity - Manual: Sprite Masks

@mackz09 alternatively, you could attach and align several “Box Collider 2D” components to your background images and utilize the “OnTriggerEnter” methods via custom script from the Collider class. I have never used a sprite mask myself, but if you find that works better for you please share your experiences here so I can learn a thing or two about them! good luck!