Page 1 of 1

Some questions about changing actor name in c# scripts once?

Posted: Tue May 03, 2022 10:41 am
by whbe
Hi,I'm not native English speaker so my content may has some English error.
I'm new to dialogue system, and I want to create a public speaker actor so I could set different actor attribute to the public one when I come to different conversation node. And I have some problems.
Here is my code

Code: Select all

    public void SetThoughtToPublicSpeaker(string thoughtName)
    {
    //I use variables to record different actor name
        string thoughtValue = DialogueLua.GetVariable(thoughtName).asString;
        Actor publicSpeaker = DialogueManager.masterDatabase.GetActor(publicSpeakerName);
        if (publicSpeaker != null)
        {
            Debug.Log("get speaker and thought");
            publicSpeaker.Name = thoughtValue;
        }
        else
        {
            Debug.LogWarning("actor not setting");
        }
    }
First, could I set displayname in c#? I only find Name attribute to set, so I choose to set Name, and it dose work.
Second, I call this event twice in on conversation, in first called place, it worked. This public actor name change to the name I need.
But in second place, this actor name remain the last name. And in visual studio debug mode, I confirm the publicSpeaker.Name has changed to my second name. So I don't know what happened.
I don't know how to realize it or is impossible in dialogue system?
Please tell me more,. thanks!!!!

Re: Some questions about changing actor name in c# scripts once?

Posted: Tue May 03, 2022 2:27 pm
by Tony Li
Hi,

To change the publicSpeakerName's Display Name use:

Code: Select all

DialogueLua.SetActorField(publicSpeakerName, "Display Name", thoughtValue);
If this happens during an active conversation and you want it to change the dialogue UI's Portrait Name immediately, use the Lua function in the Discover Name example scene on the Dialogue System Extras page.

Re: Some questions about changing actor name in c# scripts

Posted: Tue May 03, 2022 7:37 pm
by whbe
It's useful! Thanks a lot.

Re: Some questions about changing actor name in c# scripts once?

Posted: Tue May 03, 2022 7:50 pm
by Tony Li
Glad to help!