Page 1 of 1

Reset Portrait

Posted: Mon Dec 26, 2022 2:42 pm
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!

Re: Reset Portrait

Posted: Mon Dec 26, 2022 6:45 pm
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);
        }
    }
}

Re: Reset Portrait

Posted: Wed Dec 28, 2022 9:32 am
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!

Re: Reset Portrait

Posted: Wed Dec 28, 2022 10:29 am
by Tony Li
Glad to help!