PC Portrait blinking

Announcements, support questions, and discussion for the Dialogue System.
User avatar
Tony Li
Posts: 22049
Joined: Thu Jul 18, 2013 1:27 pm

Re: PC Portrait blinking

Post by Tony Li »

Glad to help! Some games use a typewriter effect, which gives time for each portrait to display. Others only show the NPC's portrait. To only show NPC portraits with the WRPG template, tick the subtitle panel's Only Show NPC Portraits checkbox.
Maltakreuz
Posts: 40
Joined: Sat Jul 25, 2015 2:36 pm

Re: PC Portrait blinking

Post by Maltakreuz »

Just in case somebody will find this post by searching and is interested with what i ended up, here it is (just delayed setter of portrait, but works fine for me).

Code: Select all

using Text = TMPro.TextMeshProUGUI;
public class DelayedPortraitSetter : MonoBehaviour {
    [Tooltip("Original Dialogue System image, that blinks for PC too quick. Must be disabled or invisible")]
    public Image srcImg;
    [Tooltip("Queued img, that will be shown as current speaker portrait")]
    public Image dstImg;

    public Text srcTxt;
    public Text dstTxt;

    public float showPortraitDuration = 1f;
    [Tooltip("How long current portrait is already shown. Ticks from 0 upwards.")]
    public float time = 0;

    void Update() {
        time += Time.deltaTime;
        if (srcImg.sprite != dstImg.sprite && time >= showPortraitDuration) {
            dstImg.sprite = srcImg.sprite;
            dstTxt.text = srcTxt.text;
            time = 0;
        }
    }
    
    void OnEnable() {
        // to avoid delay on dialogue start
        time = showPortraitDuration;
    }
}
User avatar
Tony Li
Posts: 22049
Joined: Thu Jul 18, 2013 1:27 pm

Re: PC Portrait blinking

Post by Tony Li »

Thanks for sharing!
Post Reply