How to Change ActorName at runtime

Announcements, support questions, and discussion for the Dialogue System.
Post Reply
Monsta
Posts: 16
Joined: Fri Mar 14, 2025 11:38 am

How to Change ActorName at runtime

Post by Monsta »

Hi Tony,

I'm so happy about the DS updates! I'm always amazed by the convenient features :)
Anyway, I'm currently using DS with the EasySave3.
During on conversation, I've made it so that if the player clicks on an 'Info' UI button, change variables like their name and age at any time. I've linked the name like this in my C#Script:

Code: Select all

public void SaveName()
{
	string newSaveName = userName.text;
	DataManager.instance.ppDatas.playerName = newSaveName;
	DialogueManager.ChangeActorName("Player", newSaveName); 
}
like this, but the character name of the text panel changed right away during runtime,
but [var=Actor] Tag used in the Dialogue Text didn't change. so:

Code: Select all

DialogueLua.SetVariable("PlayerName", newSaveName);
I added this code and did [var=PlayerName], and it changed right away.

a better method for the [var=Actor] tag to reflect the changed name immediately?
(Of course, it does change if I restart the conversation or scene,,,, but...)
Last edited by Monsta on Tue May 27, 2025 8:11 pm, edited 2 times in total.
User avatar
Tony Li
Posts: 23238
Joined: Thu Jul 18, 2013 1:27 pm

Re: How to Change ActorName at runtime

Post by Tony Li »

Hi,

Use this patch:

DS_ChangeActorName_2025-05-27.unitypackage

Or add one line to your method:

Code: Select all

public void SaveName()
{
    string newSaveName = userName.text;
    DataManager.instance.ppDatas.playerName = newSaveName;
    DialogueManager.ChangeActorName("Player", newSaveName);
    DialogueLua.SetVariable("Actor", newSaveName);
}
The patch is more complete because it also handles [var=Conversant] if applicable.
Monsta
Posts: 16
Joined: Fri Mar 14, 2025 11:38 am

Re: How to Change ActorName at runtime

Post by Monsta »

It works perfectly at runtime! Thanks, Tony!
User avatar
Tony Li
Posts: 23238
Joined: Thu Jul 18, 2013 1:27 pm

Re: How to Change ActorName at runtime

Post by Tony Li »

Glad to help!
Post Reply