getting a list of actors from the database in the editor

Announcements, support questions, and discussion for the Dialogue System.
Post Reply
destrucity
Posts: 24
Joined: Mon Feb 11, 2019 6:29 pm

getting a list of actors from the database in the editor

Post 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!
destrucity
Posts: 24
Joined: Mon Feb 11, 2019 6:29 pm

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

Post 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!
User avatar
Tony Li
Posts: 22056
Joined: Thu Jul 18, 2013 1:27 pm

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

Post 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.
destrucity
Posts: 24
Joined: Mon Feb 11, 2019 6:29 pm

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

Post by destrucity »

Wow that works great, talk about making it easy. Thanks!
User avatar
Tony Li
Posts: 22056
Joined: Thu Jul 18, 2013 1:27 pm

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

Post by Tony Li »

Glad to help!
Post Reply