-
-
Save AG-Dan/941cbd2d0469618c3bb9a01f681f7b11 to your computer and use it in GitHub Desktop.
An example of how to execute a function on every instance of a custom 'MySpawnerComponent' script when the dungeon generation is completed
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using DunGen; | |
using UnityEngine; | |
public class RunSpawnerScripts : MonoBehaviour | |
{ | |
public RuntimeDungeon RuntimeDungeon = null; | |
private void OnEnable() | |
{ | |
RuntimeDungeon.Generator.OnGenerationStatusChanged += OnDungeonGenerationStatusChanged; | |
} | |
private void OnDisable() | |
{ | |
RuntimeDungeon.Generator.OnGenerationStatusChanged -= OnDungeonGenerationStatusChanged; | |
} | |
private void OnDungeonGenerationStatusChanged(DungeonGenerator generator, GenerationStatus status) | |
{ | |
if (status == GenerationStatus.Complete) | |
{ | |
foreach (var spawner in generator.Root.GetComponentsInChildren<MySpawnerComponent>()) | |
spawner.Spawn(); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment