Game Development Community

[RESOLVED]Prioritizing component registration

by Ron Barbosa · in Torque X 2D · 08/14/2010 (2:57 pm) · 1 replies

Hey all...does anyone know of a way to prioritize the registration of components as they are added to a scene object?

I know how to use [TorqueXmlSchemaDependency(typeof(blah))] to enforce (in TXB) that one component relies on another. The irony of this, however, is that TX appears to initialize/register each component on a LIFO basis. So if Component2 relies on Component1, Component1 must be added first, then Component2 is added (making Component2 the Last In and thus the First Out when it comes to registration).

I need Component1 to be fully registered and to have its _OnRegister method be completed before Component2 executes its _OnRegister method.

Is there any way to enforce this in TX?

Thanks
--RB

#1
08/14/2010 (6:52 pm)
Hey Ron,

cross posting from your other thread:

This is what I do in these cases (another ugly one): I implement a deferred and controlled initialization. The dependent component upon post registration checks if the main one is there; if it's not it does nothing and at the first other call checks if it's properly initialized and if not it performs the init again. It's not elegant but it works fine ;)

~Pino