initializationComplete?

Announcements, support questions, and discussion for the Dialogue System.
Post Reply
nicmar
Posts: 133
Joined: Wed Aug 21, 2019 2:39 am

initializationComplete?

Post by nicmar »

I need to run some code when DialogueSystem have been initalized. I can see this code in DialogueSystemController:

Code: Select all

public event System.Action initializationComplete = delegate { };
How do I subscribe to that event from another class?

I also tried to read

Code: Select all

if (DialogueSystemController.isInitialized)
but I guess I need a reference to the actual dialogueManager instance.

EDIT: I just found

Code: Select all

DialogueManager.instance.isInitialized
, but an event would probably be more efficient than polling :)

Thank you!
Working on SpaceChef - A wacky open world space western, featuring a chef with nothing to loose, after he loses everything.. ;) Follow our work on @BlueGooGames.
User avatar
Tony Li
Posts: 22055
Joined: Thu Jul 18, 2013 1:27 pm

Re: initializationComplete?

Post by Tony Li »

Hi,

Code: Select all

DialogueManager.instance.initializationComplete += OnInitializationComplete;

void OnInitializationComplete() {
    Debug.Log("Dialogue Manager is initialized");
}
Or just wait until the end of the frame. (The Dialogue System initializes in Start().)

Code: Select all

IEnumerator Start() { // No event needed.
    yield return new WaitForEndOfFrame();
    Debug.Log("Dialogue Manager is initialized");
}
Post Reply