Well, there’s still one piece of information missing, but I think I’ve got the whole picture here anyway, now.
So, let’s go back to your original script excerpt.
Since you’re seeing the segments correctly in the inspector, I’m guessing there’s not any real delay between when you’re generating the rooms (e.g. Instantiate()) and when you’re comparing them to see whether they’re already determined to be adjacent to other parts (i.e. “deadend” and “doorway” flags). I assume you’re instantiating the pieces, then checking the connections between them on the same frame.
Why would this be a problem?
OnTriggerEnter() is handled by the physics system, which wouldn’t be processed as the pieces are being generated. In fact, there’s no guarantee that physics would be processed simply before the second frame; you would need to delay verifying connections by an indeterminate amount. Still far less than the time it would take to interact with them in almost any circumstance, but a delay nevertheless.
The key problem here is that to deal with this, you either have to delay checking the rooms, or re-evaluate how you’re actually checking the neighboring rooms using a more immediate means.
The delayed option would involve using a Coroutine to stall until after a physics update is guaranteed to have taken place first and allowed OnTriggerEnter() to be processed:
for (int i = 0; i < walls.Length; i++)
Re-evaluating your approach to still function on the same frame (which, for one thing, is more sensible), can most likely be done using Physics.OverlapBox() rather than relying on OnTriggerEnter() when it gets around to it.
This would mean changing your instantiation scheme to immediately perform the checks for neighboring pieces:
// Simple example, since I don't know what you already have
// Have data gathered for here, reusing a bit
for(int i = 0; i < walls.Length; i++)
Collider collidersInRange = Physics.OverlapBox([intended side of room]center, halfExtents, orientation);
// Other options include OverlapBox() for the entire size of room, then checking direction between room segments
// or, still utilizing direction, Physics.Raycast() to check for adjacent objects
for(int j = 0; j < collidersInRange.Length; j++