Align gameobject (zone) to foundation's rotation?

I've adapted Zone Manager (for my own uses) to have a better creation tool for rectangular zones. However, my main problem is the rotation of those zones not aligning and not rotating as I would expect. I am posting this here because it's more of a general issue with rotating gameObjects, and I don't feel it's specifically related to zones.

GOAL:
Have rectangular zones that are perfectly aligned with square foundation orientation so they can be used in rectangular structures.

PROBLEM:

Because I don't necessarily know where which direction the zone needs to orientate, I get the foundation transform.rotation when the user creates the zone. I then apply that rotation to the zone.

However, it doesn't rotate it in place as I would expect. Instead it seems to rotate it around the origin of the map (red).

WHAT I'VE TRIED:

  •  ZoneManager succesfully rotates the rectangular zone with this /zone rotation flag command:
zone.definition.Rotation = Quaternion.AngleAxis(rotation, Vector3.up).eulerAngles;​
  • Rotating with respect to Space.World
  • Honestly so many other things I can't think of.


I've tried for the past 2 days and have even had someone else look at it and they tried for several hours with no success. Quaternions and 3D space is not my strong suit, so I'm shooting in the dark pretty much. I would appreciate and honestly pay for any help at this point.

KEY:
red circle = ~world origin
green wireframe = un-rotated zone with working trigger for the highlighted zone
walls next to green = intended zone area/rotation
yellow square = rotated zone with working trigger around that rough area

code gods up in here
5d66db4201195.jpg?uid=5d66db72ac9cd RyanFromRust
code gods up in here

Huh..?

uh, maybe

bool confused = true;
string urResponse;
Console.Write("You're a good a coder and I'm giving you props?");
urResponse=Console.ReadLine;
Console.WriteLine("" + urResponse + " it's true, i know i'm on umod");

I guess what you want is the transform.eulerAngles.y of the foundation. Apply this value as rotation for the zone and it should work.

Greetings

I FINALLY got it. Went back through my code and compared it to the original ZoneManager and found what problems I had done wrong. Now my only problem is the size of the zone is too large.

When creating the zone, I select 4 corners in the area I want the zone to be. However, due to the misalignment to origin, it calculates the size based on the green outlines in my first image given. So once you rotate it, it's too big for the zone.

Obviously this isn't a problem for ZoneManager because for his rectangular zones, he has the user manually set the size. However, that could be very tedious getting the zones perfectly aligned to what I need.

If anyone has any insight on shrinking the sizebased on rotation, that would be great.

Here's hwat it looks like:

dURcU2l.jpg