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.
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:
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);
}
}
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?
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).
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):
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);
}
}
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: