From c393a966538a447e4597ca39b01b51a4e1c7aa5f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20=C5=A0vec?= Date: Mon, 19 Aug 2024 22:30:41 +0200 Subject: [PATCH] Change names of objects spawned by installers --- Assets/Scripts/Installers/GlobalInstaller.cs | 23 +++++++++++++++++++- Assets/Scripts/Installers/LevelInstaller.cs | 4 ++++ 2 files changed, 26 insertions(+), 1 deletion(-) diff --git a/Assets/Scripts/Installers/GlobalInstaller.cs b/Assets/Scripts/Installers/GlobalInstaller.cs index 8263081e..8338f583 100644 --- a/Assets/Scripts/Installers/GlobalInstaller.cs +++ b/Assets/Scripts/Installers/GlobalInstaller.cs @@ -5,6 +5,8 @@ using Zenject; public class GlobalInstaller : MonoInstaller { + + [SerializeField] private GameObject musicPlayerPrefab; @@ -14,20 +16,39 @@ public class GlobalInstaller : MonoInstaller [SerializeField] private GameObject playerPrefab; + public override void Start() + { + base.Start(); + + name = "ProjectContext"; + } + public override void InstallBindings() { Container.Bind() .FromComponentInNewPrefab(musicPlayerPrefab) - .AsSingle(); + .AsSingle() + .OnInstantiated((ctx, obj) => + { + obj.name = musicPlayerPrefab.name; + }); Container.Bind() .FromComponentInNewPrefab(hvrGlobalPrefab) .AsSingle() + .OnInstantiated((ctx, obj) => + { + obj.name = hvrGlobalPrefab.name; + }) .NonLazy(); Container.Bind() .FromComponentInNewPrefab(playerPrefab) .AsSingle() + .OnInstantiated((ctx, obj) => + { + obj.name = playerPrefab.name; + }) .NonLazy(); } } \ No newline at end of file diff --git a/Assets/Scripts/Installers/LevelInstaller.cs b/Assets/Scripts/Installers/LevelInstaller.cs index 9bcf40fc..4b41739b 100644 --- a/Assets/Scripts/Installers/LevelInstaller.cs +++ b/Assets/Scripts/Installers/LevelInstaller.cs @@ -15,6 +15,10 @@ public class LevelInstaller : MonoInstaller Container.Bind() .FromComponentsInNewPrefabResource("Managers/LevelManager") .AsSingle() + .OnInstantiated((ctx, obj) => + { + obj.name = "LevelManager"; + }) .NonLazy(); } } \ No newline at end of file