I’m trying to inject(DI) an object to a bunch of other scripts without doing statically, is there a way to do that?
For example:
public class InitGame : MonoBehaviour {
void Start() {
TileMape tileMap = ...
}
}
public class AnotherScript : MonoBehaviour {
public TileMap tileMap;
void AnotherScript (TileMap injectedTileMap): base() {
tileMap = injectedTileMap;
tileMap.DoStuff();
}
}
How can I do something like this without making the TileMap instance static or using the singleton design pattern?