Add Image to Quest

Announcements, support questions, and discussion for the Dialogue System.
Post Reply
cruddish
Posts: 9
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: 23431
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: 9
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: 23431
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.
cruddish
Posts: 9
Joined: Mon Dec 02, 2024 3:20 pm

Re: Add Image to Quest

Post by cruddish »

Sorry for repeated questions, what is the best way to unpack the prefab and replace it (as mentioned in that post for 2022+)? Tried dragging it into a scene, unpacking it there, swapping out the script, and then turning it back into a prefab again and setting that as the prefab to be instantiated, but that appeared to break the menu (it no longer showed any quests).
User avatar
Tony Li
Posts: 23431
Joined: Thu Jul 18, 2013 1:27 pm

Re: Add Image to Quest

Post by Tony Li »

Hi,

Did you replace the script in-place by assigning your subclass script to the original StandardUIQuestLogWindow component's Script field?

Here's an example scene with the example script:

DS_QuestImageExample_2025-07-13.unitypackage
cruddish
Posts: 9
Joined: Mon Dec 02, 2024 3:20 pm

Re: Add Image to Quest

Post by cruddish »

I seem to be getting an "Object reference not set to an instance of an object" error for the following line:

Code: Select all

var imageName = DialogueLua.GetQuestField(quest.Title, "Drawing").asString;
The new custom field is indeed called Drawing, so not sure why this would be the case. Below is the full script (just slightly edited from the one you supplied):

Code: Select all

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

public class DrawingQuestLogWindow : StandardUIQuestLogWindow
{
    public Image drawing;

    protected override void RepaintSelectedQuest(QuestInfo quest)
    {
        // Get the quest's image name from the custom field "SplashImage":
        var imageName = DialogueLua.GetQuestField(quest.Title, "Drawing").asString;
        // Load the image from Resources and set the UI Image:
        drawing.sprite = Resources.Load<Sprite>(imageName);
        base.RepaintSelectedQuest(quest);
    }
}
User avatar
Tony Li
Posts: 23431
Joined: Thu Jul 18, 2013 1:27 pm

Re: Add Image to Quest

Post by Tony Li »

Hi,

Please check the version of that method that's in the example scene. I added some error checking that I omitted from the forum reply for clarity. For reference, that method is:

Code: Select all

protected override void RepaintSelectedQuest(QuestInfo quest)
{
    splashImage.enabled = quest != null;
    if (quest != null)
    {
        var imageName = DialogueLua.GetQuestField(quest.Title, "SplashImage").asString;
        splashImage.sprite = Resources.Load<Sprite>(imageName);
    }
    base.RepaintSelectedQuest(quest);
}
cruddish
Posts: 9
Joined: Mon Dec 02, 2024 3:20 pm

Re: Add Image to Quest

Post by cruddish »

Amazing that worked, thank you so much! Figured it could be to do with empty fields.
User avatar
Tony Li
Posts: 23431
Joined: Thu Jul 18, 2013 1:27 pm

Re: Add Image to Quest

Post by Tony Li »

Glad to help!
Post Reply