Page 1 of 1

[SOLVED] Selecting a conversation using a popup instead of a string?

Posted: Thu Jun 20, 2019 1:29 am
by mdotstrange
I have a custom script I use to play conversations that is attached to my Npc's-

It uses StartConversation with a "Conversation" string variable- it all works perfectly- my issue is that my game has a lot of conversations :o and some of them have long names like "GLife/SlaveBot_OutsideBossRoom"

Right now I'm typing out or copy pasting the dialog names into my public "Conversation" variable which works but it would be so much easier and cleaner if I could select the conversation name from a popup like the one that appears in the conversation window-

I noticed that the conversation names are stored in a List<Conversation>in the Database object-

I tried to use that to populate a popup in my script using Odin Inspector- it was very flaky and didn't work all the time so I went back to manually inputting the conversation name.

There's probably a way to do it with that List<Conversation> but I'm unable to :(

Is there a way to load in conversation name strings in our scripts without doing it manually?

Thank you.

Edit: I modified my Odin solution and it does work- but wondering if there's something cleaner...

Code: Select all

public string Conversation;
[ValueDropdown("DatabaseConversations")]
public string SelectedConversation;
public DialogueDatabase Database;
List<string> DatabaseConversations = new List<string>();

[Button]
void RefreshConversations()
{
DatabaseConversations.Clear();

for (int index = 0; index < Database.conversations.Count; index++)
{
var i = Database.conversations[index];

if (i.Title != "")
{
DatabaseConversations.Add(i.Title);
}

}
}

[Button]
void SetActiveConversation()
{
Conversation = SelectedConversation;
}

Re: Selecting a conversation using a popup instead of a string?

Posted: Thu Jun 20, 2019 9:07 am
by Tony Li
Hi,

If you add the [ConversationPopup] attribute to the string, it will use a popup. So instead of this:

Code: Select all

public string Conversation;
use this:

Code: Select all

[ConversationPopup] public string Conversation;

Re: Selecting a conversation using a popup instead of a string?

Posted: Thu Jun 20, 2019 2:34 pm
by mdotstrange
Ah, that's brilliant! Thank you!

I'm using the Database selection field and it works great- curious though as to how to use it without showing the database selection field?

Before setting it to true as shown in the docs I wasn't able to select any dialogues-

Re: Selecting a conversation using a popup instead of a string?

Posted: Thu Jun 20, 2019 3:21 pm
by Tony Li
If you exclude (true), then the currently-open scene needs to have a Dialogue Manager with the dialogue database assigned to it. The popup will use the conversations in this database.

BTW, I subscribed to Game Dev Grit. I've only listened to your interview with Ash Blue so far. (Wish I had more time to listen to podcasts!)

Re: Selecting a conversation using a popup instead of a string?

Posted: Thu Jun 20, 2019 4:59 pm
by mdotstrange
Ok, that makes sense- thank you!

Ah cool- would love to have you on as a guest sometime if you are interested and have time. I've been using your brilliant Dialogue System and Scene Streamer for a few years now and I've seen your wealth of knowledge from your posts on the Unity forums ^_^