Page 1 of 1

getting a list of actors from the database in the editor

Posted: Mon Feb 11, 2019 6:34 pm
by destrucity
I'd like to make a custom editor with a dropdown list composed of all of the actors in my main database.

I've tried this, but trying to access MasterDatabase (and masterDatabase) results in a null reference exception:

Code: Select all

public override void OnInspectorGUI()
{
var test = PixelCrushers.DialogueSystem.DialogueManager.MasterDatabase.actors;
}
Is there a way to access the actors in the masterDatabase in the editor? Thanks!

Re: getting a list of actors from the database in the editor

Posted: Mon Feb 11, 2019 6:39 pm
by destrucity
It seems like a solution may be to use GameObject.FindObjectOfType<PixelCrushers.DialogueSystem.DialogueSystemController>()

but if there is a better way, please let me know!

Re: getting a list of actors from the database in the editor

Posted: Mon Feb 11, 2019 8:20 pm
by Tony Li
Can you use the [ActorPopup] attribute? This is the easiest way to present a dropdown list of actors.

Otherwise, since DialogueManager.masterDatabase is only valid at runtime, you can call EditorTools.FindInitialDatabase(), which returns the database that's assigned to the Dialogue Manager's Initial Database in the currently-open scene.

Re: getting a list of actors from the database in the editor

Posted: Tue Feb 12, 2019 10:26 am
by destrucity
Wow that works great, talk about making it easy. Thanks!

Re: getting a list of actors from the database in the editor

Posted: Tue Feb 12, 2019 10:48 am
by Tony Li
Glad to help!