Advertisement
Feynom

Untitled

Apr 16th, 2024
95
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.76 KB | None | 0 0
  1. using UnityEngine;
  2. using Zenject;
  3.  
  4. namespace Tests
  5. {
  6. [DefaultExecutionOrder(-9990)]
  7. [RequireComponent(typeof(GameObjectContext))]
  8. public class GameObjectContextRunner : MonoBehaviour
  9. {
  10. #region MonoBehaviour
  11.  
  12. private void Awake() => Run();
  13.  
  14. #endregion
  15.  
  16. private void Run()
  17. {
  18. GameObjectContext gameObjectContext = GetComponent<GameObjectContext>();
  19.  
  20. if (gameObjectContext.Initialized)
  21. return;
  22.  
  23. DiContainer parentContainer = ProjectContext.Instance.Container
  24. .Resolve<SceneContextRegistry>()
  25. .GetContainerForScene(gameObject.scene);
  26.  
  27. gameObjectContext.Construct(parentContainer);
  28. }
  29. }
  30. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement