Page 1 of 1

initializationComplete?

Posted: Thu Aug 29, 2019 3:50 pm
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!

Re: initializationComplete?

Posted: Thu Aug 29, 2019 4:40 pm
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");
}