Good day.
I have fallowing object structure:
![alt text][1]
[1]: http://cs14102.vk.me/c312319/v312319240/6aeb/HB20GW8KTsY.jpg
The "Ship" object contains a bunch of "Subsystem" components. Three "TwoOnOne" objects is a rooms of the ship. Each room must represent one subsystem (also multiple rooms can represent the same subsystem). I want to write an editor extention for a "Room" component that will load all "Subsystems" from the Ship to a popup and will allow a map designer to just select it from a list. But I need to load subsystems only from this particular Ship. Assign a ship object to each room manually is a bit boring and can lead to some ugly errors if map designer forgot to assign it. So I need a way to assign it in code. Normally in game I write a Start function in a "Ship" component, that just assigns this ship to each room below. Like this:
Rooms = new List();
var rooms = GetComponentsInChildren();
if (rooms != null)
{
foreach (ShipRoom room in rooms)
{
RegistedRoom(room);
}
}
But in the Editor the Start function doesn't work. Could you please tell me a Start function analogue that works in editor? I tried to use OnEnable function, but it still doesn't fire in Editor. May be I do something wrong?
↧