Page 1 of 1

How to reference conversations via inspector

Posted: Thu Oct 06, 2022 7:30 am
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!

Re: How to reference conversations via inspector

Posted: Thu Oct 06, 2022 7:44 am
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.

Re: How to reference conversations via inspector

Posted: Thu Oct 06, 2022 8:33 am
by yurijh
Very nice, thanks!

Re: How to reference conversations via inspector

Posted: Thu Oct 06, 2022 8:35 am
by Tony Li
Happy to help!