Add Image to Quest

Announcements, support questions, and discussion for the Dialogue System.
Post Reply
cruddish
Posts: 6
Joined: Mon Dec 02, 2024 3:20 pm

Add Image to Quest

Post by cruddish »

Hi Tony!

I was wondering if there was a way to attach an image to a Quest and have it displayed on the Standard Quest Log UI, the way you can define its Name, Description and Entries. I want to have unique splash art for each quests, similar to how Dragon Age Inquisition does it for theirs. I did try creating a custom field using the dialogue system to maybe slot images in, but I had no way of actually calling it in the Standard Quest Log UI.

Let me know and thanks!!!

Image
User avatar
Tony Li
Posts: 23418
Joined: Thu Jul 18, 2013 1:27 pm

Re: Add Image to Quest

Post by Tony Li »

Hi,

In version 3, this will be built in. Until then, you can put an image in a Resources folder and add the image's filename to a custom field in your quest. Then make a subclass of StandardUIQuestLogWindow and override the RepaintSelectedQuest() method. Also add a variable for the splash art UI Image that you can assign in the inspector. In the RepaintSelectedQuest() method, set the UI Image. Something like:

Code: Select all

using UnityEngine;
using UnityEngine.UI;
using PixelCrushers.DialogueSystem;

public class SplashArtQuestLogWindow : StandardUIQuestLogWindow
{
    public Image splashImage;

    protected override void RepaintSelectedQuest(QuestInfo quest)
    {
        // Get the quest's image name from the custom field "SplashImage":
        var imageName = DialogueLua.GetQuestField(quest.Title, "SplashImage").asString;
        // Load the image from Resources and set the UI Image:
        splashImage.sprite = Resources.Load<Sprite>(imageName);
        base.RepaintSelectedQuest(quest);
    }
}
cruddish
Posts: 6
Joined: Mon Dec 02, 2024 3:20 pm

Re: Add Image to Quest

Post by cruddish »

Thanks for getting back! Once I've made this subclass, do I use this new component instead of the StandardUIQuestLogWindow? Or do I use both in tandem, simply using the new one for the Image field?
User avatar
Tony Li
Posts: 23418
Joined: Thu Jul 18, 2013 1:27 pm

Re: Add Image to Quest

Post by Tony Li »

Use this one in place of the regular StandardUIQuestLogWindow. You can replace it in-place.
Post Reply