diff --git a/website/docs/registering/register-factory.mdx b/website/docs/registering/register-factory.mdx index b1027bef..02865806 100644 --- a/website/docs/registering/register-factory.mdx +++ b/website/docs/registering/register-factory.mdx @@ -67,3 +67,22 @@ class ClassA } ``` +In this case, container.Instantiate etc. are also useful. + +```csharp +builder.RegisterFactory(container => +{ + return characterType => + { + var characterPrefab = ... + return container.Instantiate(characterPrefab, parentTransform); + } +}, Lifetime.Scoped); +``` + +See [Use Container directory](../resolving/use-container-directory) more information. + +:::note +`Func <>` factory is like a short hand. +In complex cases, consider defining and registering your own factory class。 +::: diff --git a/website/docs/resolving/assets/screenshot_auto_inject_gameobjects.png b/website/docs/resolving/assets/screenshot_auto_inject_gameobjects.png new file mode 100644 index 00000000..2716cc21 Binary files /dev/null and b/website/docs/resolving/assets/screenshot_auto_inject_gameobjects.png differ diff --git a/website/docs/resolving/auto-inject-gameobjects.mdx b/website/docs/resolving/auto-inject-gameobjects.mdx index 750de892..ab92b0c8 100644 --- a/website/docs/resolving/auto-inject-gameobjects.mdx +++ b/website/docs/resolving/auto-inject-gameobjects.mdx @@ -5,3 +5,5 @@ title: Auto inject GameObject in the scene In VContainer, objects that are not explicitly registered will not be injected. Therefore, execute Register for the object you want to inject. If you want to run **"Inject Only"** into MonoBehaviour, you can do so by inserting GameObject in the `autoInjectGameObject` field of LifetimeScope. + +![](./assets/screenshot_auto_inject_gameobjects.png) \ No newline at end of file diff --git a/website/docs/resolving/use-container-directory.mdx b/website/docs/resolving/use-container-directory.mdx index 6dad9a59..51287b3f 100644 --- a/website/docs/resolving/use-container-directory.mdx +++ b/website/docs/resolving/use-container-directory.mdx @@ -23,7 +23,7 @@ class ClassA // Instantiate with Inject container.Instantiate(prefab); container.Instantiate(prefab, parent); - container.Instantiate(prefab, position, rotation parent); + container.Instantiate(prefab, position, rotation, parent); } } ```