Retrieve name of GameObject in Dialogue

Announcements, support questions, and discussion for the Dialogue System.
Post Reply
hillka28
Posts: 4
Joined: Thu Jan 07, 2021 11:04 pm

Retrieve name of GameObject in Dialogue

Post by hillka28 »

First off, thank you for building such an amazing system - your documentation is really thorough, and I have been loving how powerful this is as I continue using it and learning.

In my game, there are "road signs" (i.e. starting a conversation with it will have it read "Route 2" or "Kentucky", and so on). Basically, a non-living readable object. Instead of creating an actor for each of these road signs, I was hoping to reuse one conversation and simply have the dialogue text display the name of the actor game object so that I can use the exact same road sign prefab while only changing the gameobject's name. Is this something that is possible? I've tried a number of solutions, and when debugging with the Info setting on, it did print the following:

Code: Select all

Dialogue System: Starting conversation 'Road Sign', actor=Route 2(UnityEngine.Transform), conversant=Player (UnityEngine.Transform).UnityEngine.Debug:Log(Object, Object)
This is what I was hoping to see, but when I call the conversant variable in the Dialogue Text field, it returns an empty string (I assume because the Conversant dropdown is empty, but I thought I read that it then defaults to the gameobject name which was printed in the log above). Below is my super basic configuration:







If you need any additional information, just let me know. Thanks for your time!
User avatar
Tony Li
Posts: 22051
Joined: Thu Jul 18, 2013 1:27 pm

Re: Retrieve name of GameObject in Dialogue

Post by Tony Li »

Hi,

Add a Dialogue Actor component to the Route 2 GameObject.

Click the round button to the right of the Actor dropdown to turn it into a text entry field. Then enter "Route 2".
hillka28
Posts: 4
Joined: Thu Jan 07, 2021 11:04 pm

Retrieve name of GameObject in Dialogue

Post by hillka28 »

That worked perfectly, thank you so much for your help!
User avatar
Tony Li
Posts: 22051
Joined: Thu Jul 18, 2013 1:27 pm

Re: Retrieve name of GameObject in Dialogue

Post by Tony Li »

Glad to help!
Post Reply