Page 1 of 2

Making a Quest List GUI

Posted: Mon Jun 22, 2015 4:30 pm
by SuperSparkplug
Hi there,

I was thinking of making an on screen GUI showing what tasks in my game need to be completed so its easier to keep track of the player's to-do list.

How would I access these variables while scripting for the GUI?

Re: Making a Quest List GUI

Posted: Tue Jun 23, 2015 11:09 am
by Tony Li
Hi,

Use the QuestLog class. If you need lower-level access, use DialogueLua.Get/SetQuestField(). And if you need really low level access, use Lua.Run().

Take a look at Scripts/Supplemental/Utility/QuestTracker.cs for legacy Unity GUI, or Scripts/Supplemental/UI/Scripts/Quest Log Window/UnityUIQuestTracker.cs for the Unity UI. These may do everything you need without having to write any code of your own. See the Quest Tracker HUD Setup page, and play the scene in Examples/Quest Example to get an idea of how they work.

One thing frequently throws people: Quests can have two custom fields that affect whether they're shown in the quest tracker HUD. The Boolean Trackable field specifies whether a quest is allowed to be shown in the quest tracker HUD. The Boolean Track field specifies whether to show the quest in the HUD right now. This page has some examples of both of these fields.

Re: Making a Quest List GUI

Posted: Thu Jun 25, 2015 5:00 am
by SuperSparkplug
Ah I see.

I HIGHLY recommend you update the video and written documentation on this topic because it is frustratingly out of date with how Unity currently is and how it and your system works. There's stuff in both sets of documentation that no longer exist or are in completely different places. It made figuring out what you were talking about very difficult.

Image

I'm currently trying to get a task list of quests to show up in the top left of my screen. However, I'm running into an issue I'm not sure how to tackle, given how the Dialogue system works and my limited skill in programming. I can get the game to autotrack quests with the Track variable in the Quest settings. However, how do I set it so that it appears inside my "To-Do List" window here? Currently, it appears behind the window (also its alignment is very strange for some reason as its currently set to Bottom left, not top left, to get to the top left corner). I'm not sure how to access the variable appropriately here since there's no Dialogue System text GUI function. I currently have a panel placed in the window so I can place text inside it, but I'm not sure if that helps or is appropriate in this situation.

How do I make it so that the quest name will automatically appear in the top-left window? Also, is there a way to alter the size and font of the text in these specialized GUI objects?

Re: Making a Quest List GUI

Posted: Thu Jun 25, 2015 1:48 pm
by Tony Li
Hi,

Sorry about the frustration and difficulties. I'll take a good look at the documentation before the next release. I appreciate your feedback to let me know which areas of the manual need the most immediate attention.

It appears that you're using the legacy Unity GUI quest tracker. If you're using Unity 4.6+, you may find it easier to work with the Unity UI quest tracker. If you do, just drop in the prefab and customize it. Open the example scene in Scripts/Supplemental/UI/Example to see how it works. It's located under the "Canvas" GameObject.

Looking at the legacy Unity GUI quest tracker, you have a GUI Root. All UI elements will use the GUI Root's GUI Skin settings except the quest name itself. The quest name will use the GUI Skin assigned to the Quest Tracker component. It's done this way so you can add just a QuestTracker to your scene without having to set up a GUI Root or any other GUI elements.

The quest name will use the GUI style named in the Quest Tracker's Title Style field. If Title Style is blank, it will use the GUI Skin's default label style. GUI styles have alignments that affect where the text is positioned.

The legacy Unity GUI quest tracker draws quest names in the area defined by the Quest Tracker's Rect field, which is a scaled rect. Configure it to overlap the area inside the GUI Window where you want quests to appear.

This is fairly rudimentary, but that's intentional because every project's quest tracking UI is very different. The Dialogue System has robust hooks to update and retrieve quest tracking data, but the quest tracker UI code was kept short and simple to make it easy for developers to pull apart and customize as they see fit (or replace entirely with visual scripting actions such as PlayMaker).

If I can do anything else to help you set this up, please let me know. I'm sure you want to get back to actually writing your content, not fiddling with this UI stuff. In the near future, I'll also be posting a tutorial video on setting up a Unity UI quest tracker.

Re: Making a Quest List GUI

Posted: Fri Jun 26, 2015 1:12 am
by SuperSparkplug
Thank you for the reply, but what your talking about is kind of the issue and why I was having so much trouble. In the entirety of the Dialogue System files there is no Unity UI Quest Tracker. Just a regular Quest Tracker. There also is not a UI folder where you're telling me to look. I don't know if Pixel Crushers changed the system recently, but things such as that just simply aren't there, which is why its been frustrating trying to find it.

Re: Making a Quest List GUI

Posted: Fri Jun 26, 2015 2:50 am
by SuperSparkplug
Okay, so it seems that for some odd reason, even though I set it to import the entire Dialogue system when I began my project, it did not include those UI files you mentioned for some reason. After some shenanegans with the files, I was able to copy the UI section you were talking about into my project. NOW some of what you were talking about makes sense.

Still a problem though. Following your instructions, I cannot get the Quest Tracker Template to work. It seems to be missing a script that's supposed to be attached to it. Additionally, I cannot add the Quest Tracker Template to the Unity UI Quest Tracker, possibly because of this. Going through the examples, they are also missing the script on the Quest Tracker Template. Perhaps there is more that could be imported, but I am wary because I tried straight replacement of the old Dialogue System folder in my project with a brand new one and it broke A LOT of things. I was able to set things right I think but judging from a few odd things, I think I may have broken something when I tried to do that. I looked through the documentation and can't seem to figure out what is supposed to be attached to it. Any ideas?

Re: Making a Quest List GUI

Posted: Fri Jun 26, 2015 9:58 am
by Tony Li
Hi,

Are you using Unity 4.x? If so, then to enable Unity UI support, you have to import "Assets/Dialogue System/Scripts/Unity UI Support.unitypackage". This will add all of the missing Unity UI support scripts.

Some developers are working on projects (mostly for older consoles) that are platform-locked on Unity 4.3, which predates Unity UI, so the Unity UI files needed to be kept separate for Unity 4.x.

Fortunately, the last developer that I'm aware of using 4.3 recently released their game, so the next version will require a minimum of Unity 4.6.5. This means Unity UI support can be included by default without having to import anything extra.

If that doesn't help, please let me know -- and feel free to send an example project to tony (at) pixelcrushers.com any time. I'll be happy to take a look.

Re: Making a Quest List GUI

Posted: Fri Jun 26, 2015 1:13 pm
by SuperSparkplug
I'm currently using Unity 5.

I was able to figure out the missing script link by importing the Dialogue System into a separate blank project so it works now.

The last thing, I think, for this issue is that I was able to get my "To-Do List" to work, however, I'm trying to make it so that the end of one quest triggers another. However, I can't seem to get it to set the new quest as active now that one quest has been completed. I set a lua command on the parameter that completes the first quest, which is accomplished by entering an area. However, the new quest does not get put to active. I even made a second trigger parameter and it still does not work. The quest does seem to work if I set it to be active on start, so it does work and it is Track and Trackable. Not sure why it won't activate itself on trigger.

Thanks for the offer. If I keep having issues, I'll send it, but I want to try and figure it out myself first.

Re: Making a Quest List GUI

Posted: Fri Jun 26, 2015 2:02 pm
by Tony Li
Is the quest active internally in the Quest[] table? You can check this by opening the Dialogue Editor. At runtime, the Template tab turns into a Watch tab. Add a watch for the quest, such as:

Code: Select all

Quest["My_Quest_Title"].State
In a build, or if you don't want to use the Dialogue Editor, you can add a Lua Console to your scene. Then press ~+L and enter a Lua command such as:

Code: Select all

return Quest["My_Quest_Title"].State
If it's active in the Quest[] table, you may just need to tell your quest tracker GUI to update itself by sending the message "UpdateTracker". What component(s) or methods are you using to change the quest states? If you're using a Quest Trigger, you can configure the Send Messages section to send "UpdateTracker" to the GameObject that contains the quest tracker component.

Re: Making a Quest List GUI

Posted: Fri Jun 26, 2015 4:59 pm
by SuperSparkplug
It doesn't seem so. When I added the watch, it says in the console:
Dialogue System: Lua code 'return Quest["My_Quest_Title"].State' threw exception 'Lookup of field 'State' in the table element failed because the table element itself isn't in the table.'
UnityEngine.Debug:LogError(Object)
PixelCrushers.DialogueSystem.Lua:RunRaw(String, Boolean, Boolean)
PixelCrushers.DialogueSystem.Lua:Run(String, Boolean, Boolean)
PixelCrushers.DialogueSystem.Lua:Run(String)
PixelCrushers.DialogueSystem.DialogueEditor.Watch:Evaluate()
PixelCrushers.DialogueSystem.DialogueEditor.DialogueEditorWindow:DrawWatches()
PixelCrushers.DialogueSystem.DialogueEditor.DialogueEditorWindow:DrawWatchSection()
PixelCrushers.DialogueSystem.DialogueEditor.DialogueEditorWindow:DrawCurrentSection()
PixelCrushers.DialogueSystem.DialogueEditor.DialogueEditorWindow:DrawMainBody()
PixelCrushers.DialogueSystem.DialogueEditor.DialogueEditorWindow:OnGUI()
UnityEditor.DockArea:OnGUI()
Am I supposed to be adding it to a table of some sort?

Currently, I have a Quest Trigger that enters a success for the first quest upon intering a trigger area. I've then set Lua code in that trigger as

Code: Select all

Quest["Go_to_work"].State = "active"