Page 1 of 1

Showing the NPS image throughout the dialog box

Posted: Thu Apr 02, 2020 6:25 am
by Stalker_EG
Good afternoon!
I have a question.
I created my dialogue template. There is one text panel for PC and NPS (character name and text.) but I need to constantly show the NPS image in the center of the screen first and until the end of the dialog. If I create a separate panel for the NPS then the image only appears when it has a replica in the dialog.

I hope that I have explained what I want to achieve in a way that is accessible.

Re: Showing the NPS image throughout the dialog box

Posted: Thu Apr 02, 2020 8:20 am
by Tony Li
Hi,

Can you do the following?
  • Assign the center NPS image to the NPC Subtitle Panel's Portrait Image. Deactivate the other portrait image that is inside the subtitle panel.
  • Set the NPC Subtitle Panel's Visibility to Always From Start.
Note: This will show the NPC Subtitle Panel when the conversation starts. it will not hide until the conversation ends.

If you need to hide the NPC Subtitle Panel when the PC is playing a subtitle, then you cannot use the steps above. Instead:
  • Leave the NPC Subtitle Panel's Portrait Image unassigned.
  • Add this script to your dialogue UI or Dialogue Manager, and assign the center NPC image to it:
SetNPSImage.cs

Code: Select all

using UnityEngine;
using UnityEngine.UI;
using PixelCrushers.DialogueSystem;
public class SetNPSImage : MonoBehaviour
{
    public Image NPSImage;
    
    void OnConversationLine(Subtitle subtitle)
    {
        if (subtitle.speakerInfo.isNPC) NPSImage.sprite = subtitle.speakerInfo.portrait;
    }
}

Re: Showing the NPS image throughout the dialog box

Posted: Thu Apr 02, 2020 1:32 pm
by Stalker_EG
Thank you very much for the quick response. I'm gonna try to make these decisions today. I'll be sure to report the result.