How to reference conversations via inspector

Announcements, support questions, and discussion for the Dialogue System.
Post Reply
yurijh
Posts: 13
Joined: Thu Oct 06, 2022 6:49 am

How to reference conversations via inspector

Post by yurijh »

Hi everyone,
I start conversations via code through

Code: Select all

StartConversation(string title)
I would like to have a field in inspector on certain GameObjects, that shows me a reference to all conversations in the conversations database. Just like in the conversations editor.
A typical use would be the scenario in which I want to define a collection of conversations that that script will start.

My current workaround is making a static class with the references

Code: Select all

[Flags]
public enum Conversations 
{
	Welcome = 1 << 0,
	Test1   = 1 << 1,
	Test2   = 1 << 2,
	//etc...
}
And to start the conversatios

Code: Select all

m_rDialogueSystemController.StartConversation(nameof(DialogueSystemRefs.Conversations.Welcome));
I'd like to remove that horrific enum and use something else that avoids to me to write modify code everytime I add a new conversation or I modify the conversation title.

Thanks in advance to everyone!
User avatar
Tony Li
Posts: 22143
Joined: Thu Jul 18, 2013 1:27 pm

Re: How to reference conversations via inspector

Post by Tony Li »

Hi,

Use the [ConversationPopup] attribute.

Conversations are referenced by title, which has its pros and cons. The con is that if you want to rename a title and automatically update all references in scenes, prefabs, and ScriptableObjects, use the Asset Renamer tool. Name your variable "conversation" or "conversationTitle" to help the Asset Renamer find it more efficiently.
yurijh
Posts: 13
Joined: Thu Oct 06, 2022 6:49 am

Re: How to reference conversations via inspector

Post by yurijh »

Very nice, thanks!
User avatar
Tony Li
Posts: 22143
Joined: Thu Jul 18, 2013 1:27 pm

Re: How to reference conversations via inspector

Post by Tony Li »

Happy to help!
Post Reply