Page 1 of 1

Listener Keyword in Custom Sequence Script

Posted: Sat Apr 14, 2018 7:53 pm
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!

Re: Listener Keyword in Custom Sequence Script

Posted: Sat Apr 14, 2018 10:58 pm
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);
}

Re: Listener Keyword in Custom Sequence Script

Posted: Sun Apr 15, 2018 12:56 am
by Elin Ramsey
Thank you!

Exactly what I needed and more :D

Re: Listener Keyword in Custom Sequence Script

Posted: Sun Apr 15, 2018 10:11 am
by Tony Li
Glad to help!