@@ -593,6 +593,9 @@ b.WithStartup<Startup>(o => o.Start());
593593
594594# ManualDi.Unity3d
595595
596+ When using the container in unity, do not rely on Awake / Start. Instead rely on Inject / Initialize.
597+ You can still use Awake / Start if the classes involved are not injected through the container.
598+
596599## Installers
597600
598601The container provides two specialized Installers
@@ -808,11 +811,20 @@ public class Data
808811}
809812public class SceneFacade
810813{
811- public void DoSomething () { .. . }
814+ [Inject ] Data Data { get ; set ; }
815+
816+ public void DoSomething ()
817+ {
818+ Console .WriteLine (Data .Name );
819+ }
812820}
813821public class SceneEntryPoint : MonoBehaviourSubordinateEntryPoint <Data , SceneFacade >
814822{
815- ...
823+ public override void Install (DiContainerBindings b )
824+ {
825+ b .Bind <Data >().Default ().FromInstance (Data );
826+ b .Bind <SceneFacade >().Default ().FromConstructor ();
827+ }
816828}
817829
818830class Example
@@ -830,6 +842,27 @@ class Example
830842}
831843```
832844
845+ and this is an example of how you could use a subordinate prefab
846+
847+
848+ ``` csharp
849+ class Example : MonoBehaviour
850+ {
851+ public SceneEntryPoint EntryPoint ;
852+
853+ void Start ()
854+ {
855+ var data = new Data () { Name = " Charles" };
856+ var facade = entryPoint .Initiate (data )
857+
858+ facade .DoSomething ();
859+ }
860+ }
861+ ```
862+
863+ The container provides you with the puzzle pieces necessary. The actual composition of these pieces is up to you to decide.
864+ Feel free to ignore the container classes and implement your custom entry points if you have any special need.
865+
833866## Link
834867
835868When binding things to the container, further actions can be done on the bindings
0 commit comments