Reset Portrait

Announcements, support questions, and discussion for the Dialogue System.
Post Reply
Kamotachi
Posts: 44
Joined: Fri Nov 29, 2019 9:03 pm

Reset Portrait

Post by Kamotachi »

Hi there!
It had been a long time since I wrote here! I've been using PixelCrushers DialogueSystem like it's a life saver for devs!

In my dialog system I've made avatars/pictures appear, I change them with SetPortrait( ActorName , pic= number) in the sequencer.

There are moments where I want a character to speak, but I don't want to show their avatar.
For this I've created a Portrait with an empty image and I call it with
SetPortrait (ActorName , pic= numberContainsEmptyPic).

However, when the dialogue ends I need to put again in SetPortrait(ActorName , pic= 1 ) because if not, I need to do this in every dialogue at start. (Because the dialogue system remember which picture is currently in use, in this case, a "invisible "picture)

My question is:

Can I make a script with a loop "for" to turn all the actor pictures to [1] and call it after the dialogues ?
Something similar to:

for (int i = 0; i < allActorsLenght ; i++)
{
SetPortrait( Actor[ i ], pic= 1)
}

Maybe I'm going around too much for something that has an easier solution?

Thanks in advance!
User avatar
Tony Li
Posts: 22140
Joined: Thu Jul 18, 2013 1:27 pm

Re: Reset Portrait

Post by Tony Li »

Hi,

Sure, you can put a script with an OnConversationEnd(Transform) method on the Dialogue Manager. Something like:

Code: Select all

public class ResetPortraitsOnConversationEnd : MonoBehaviour
{
    void OnConversationEnd(Transform actor)
    {
        foreach (var actor in DialogueManager.masterDatabase.actors)
        {
            DialogueLua.SetActorField(actor.Name, DialogueSystemFields.CurrentPortrait, string.Empty);
        }
    }
}
Kamotachi
Posts: 44
Joined: Fri Nov 29, 2019 9:03 pm

Re: Reset Portrait

Post by Kamotachi »

Tony Li wrote: Mon Dec 26, 2022 6:45 pm Hi,

Sure, you can put a script with an OnConversationEnd(Transform) method on the Dialogue Manager. Something like:

Code: Select all

public class ResetPortraitsOnConversationEnd : MonoBehaviour
{
    void OnConversationEnd(Transform actor)
    {
        foreach (var actor in DialogueManager.masterDatabase.actors)
        {
            DialogueLua.SetActorField(actor.Name, DialogueSystemFields.CurrentPortrait, string.Empty);
        }
    }
}
Thanks! Works fine!!! :D You 're our hero!
User avatar
Tony Li
Posts: 22140
Joined: Thu Jul 18, 2013 1:27 pm

Re: Reset Portrait

Post by Tony Li »

Glad to help!
Post Reply