Vector3.Scale and rotated colliders

I’m building a puzzle game, and I would like to horizontally flip pieces randomly when instantiated via code. Each piece has multiple box colliders and mesh objects as children to a container object.

I’ve tried using Vector3.Scale on my container object to flip everything at once by scaling in X by -1. Things looks great at first glance, but any of my collider objects that are rotated do not come through correctly.

The (rotated) meshes for the collider objects (just there to help me visibly see what’s going on) flip properly, but their colliders no longer match their size and orientation with the mesh. They keep their original orientation and scale down somewhat(?).

Here’s the code I am using:

Vector3 flipVector = new Vector3(-1, 1, 1);
transform.localScale = Vector3.Scale (transform.localScale, flipVector);

Does anyone know a good way around this? I can manually rotate/scale the individual elements if I have to, but that seems like a lot of extra work…

Okay, that wasn’t so bad.

What I did was handle the individual components separately. Those that no offset or rotation could simply be scaled by -1 in X to be flipped.

The rotated elements needed got a local 180 spin, then I used Reflect on their localPosition. Offset colliders that weren’t rotated got the same Reflect treatment but without the spin.