ssannandeji / Zenject-2019

Dependency Injection Framework for Unity3D
MIT License
2.52k stars 363 forks source link

Using UnityEvent for Pre/Post event hooks in SceneContext #578

Closed taylank closed 5 years ago

taylank commented 5 years ago

The current way to execute custom logic before SceneContext runs is to subscribe to PreInstall. For anything in the scene to have a chance to subscribe to PreInstall before the context runs, auto-run needs to be disabled. This is undesirable in situations where other MonoBehaviours in the scene execute logic in their Start() methods relying on injection to have finished.

Using UnityEvent wrapper for events circumvents this problem by allowing for hooking up methods in the inspector at design time.

svermeulen commented 5 years ago

Thanks. I've added this change with a minor modification which preserves the old style of doing it and adds yours as an alternative, to avoid breaking existing code.