Mathijs-Bakker / Extenject

Dependency Injection Framework for Unity Game Engine
MIT License
531 stars 97 forks source link

Execution order example is false in Readme #76

Open EmirSpyke opened 1 year ago

EmirSpyke commented 1 year ago

Hello, execution order example has a false comment, it says that AstroidManager gets Initialized earlier but it not true because its execution order is bigger than GameController, also in the example project this code is almost identical, only difference is that -10 and -20 are swapped which makes the comment true in the example game1, I am posting the method in the Readme:

void InitExecutionOrder()
{
    // In many cases you don't need to worry about execution order,
    // however sometimes it can be important
    // If for example we wanted to ensure that AsteroidManager.Initialize
    // always gets called before GameController.Initialize (and similarly for Tick)
    // Then we could do the following:
    Container.BindExecutionOrder<AsteroidManager>(-10);//This should be -20
    Container.BindExecutionOrder<GameController>(-20);//This should be -10

    // Note that they will be disposed of in the reverse order given here
}