Listener Keyword in Custom Sequence Script

Announcements, support questions, and discussion for the Dialogue System.
Post Reply
Elin Ramsey
Posts: 2
Joined: Sat Apr 14, 2018 7:32 pm

Listener Keyword in Custom Sequence Script

Post by Elin Ramsey »

Hi,

I am trying to use a custom sequencer command script that uses the listener as a parameter, but it is passing in the word "listener" rather the name of the actor or Game Object of the actor.

I have: A dialog entry with "AssignPlot(listener);" in the Sequence field and a custom sequencer script as follows:

Code: Select all

	public class SequencerCommandAssignPlot : SequencerCommand { 
		public void Start() {
			string villagerName = GetParameter(0);
			Debug.Log("SC Assign Plot: Listener Param: " + villagerName);
             Stop();
		}
	}
When I run this, the following is in the Debug log: "SC Assign Plot: Listener Param: listener". I would want either the name of the game object or the actor name (I have an Override Actor Name component) to be populated instead of "listener".

I found the following thread that seemed to have a similar thing: viewtopic.php?f=3&t=1165&p=6209. Per one of the troubleshooting steps I turned on the Debug Level to Info and am seeing the correct Game Object and Actor name being referenced.

I am pretty new to all of the Dialogue System, general coding, and Unity.

Thank you for any help!
User avatar
Tony Li
Posts: 22059
Joined: Thu Jul 18, 2013 1:27 pm

Re: Listener Keyword in Custom Sequence Script

Post by Tony Li »

Hi,

Instead of:

Code: Select all

string villagerName = GetParameter(0);
use:

Code: Select all

Transform villager = GetSubject(0);
This returns the transform of the GameObject named by the first parameter, or the GameObject assigned as the listener if the parameter is "listener".

If you want to translate that transform into a character name, use OverrideActorName.GetOverrideActorName(Transform):

Code: Select all

Transform villager = GetSubject(0);
string villagerName = OverrideActorName.GetOverrideName(villager);
I don't know the exact requirements of your custom sequencer command. If the parameter is not "listener", you may want to use the parameter string exactly as-is, in which case you can use this code:

Code: Select all

string villagerName = GetParameter(0);
if (string.Equals(villagerName, "listener"))
{
    Transform villager = GetSubject(0);
    villagerName = OverrideActorName.GetOverrideName(villager);
}
Elin Ramsey
Posts: 2
Joined: Sat Apr 14, 2018 7:32 pm

Re: Listener Keyword in Custom Sequence Script

Post by Elin Ramsey »

Thank you!

Exactly what I needed and more :D
User avatar
Tony Li
Posts: 22059
Joined: Thu Jul 18, 2013 1:27 pm

Re: Listener Keyword in Custom Sequence Script

Post by Tony Li »

Glad to help!
Post Reply