Skip to content

Commit 75359a7

Browse files
committed
Update README
1 parent 7a88d28 commit 75359a7

2 files changed

Lines changed: 36 additions & 3 deletions

File tree

ManualDi.Main/ManualDi.Main/ManualDi.Main.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
<Nullable>enable</Nullable>
88
<AssemblyName>ManualDi.Main</AssemblyName>
99
<RootNamespace>ManualDi.Main</RootNamespace>
10-
<Version>1.3.5</Version>
10+
<Version>1.3.6</Version>
1111
<Authors>Pere Viader</Authors>
1212
<RepositoryUrl>https://github.com/PereViader/ManualDi.Main</RepositoryUrl>
1313
<Product>ManualDi.Main</Product>

README.md

Lines changed: 35 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -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

598601
The container provides two specialized Installers
@@ -808,11 +811,20 @@ public class Data
808811
}
809812
public 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
}
813821
public 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

818830
class 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

835868
When binding things to the container, further actions can be done on the bindings

0 commit comments

Comments
 (0)