ETA On NGUI Tutorials?

Announcements, support questions, and discussion for the Dialogue System.
Post Reply
andrew2110
Posts: 39
Joined: Wed Sep 03, 2014 2:44 am

ETA On NGUI Tutorials?

Post by andrew2110 »









Hello all, I've been trying to get my GUI working with the Dialogue System. I can understand how to edit every part of the GUI apart from the little texts that prompt the user to initiate a conversation (the little yellow text in the top of the screenshot). Is there an easy way to do this? As the rest of the game is done with NGUI, it seems to make sense to use NGUI in the dialogue system too, do we have an idea when the NGUI tutorial might be coming along?
User avatar
Tony Li
Posts: 21056
Joined: Thu Jul 18, 2013 1:27 pm

ETA On NGUI Tutorials?

Post by Tony Li »

Hi Andrew,



I'll try to get video tutorials out for NGUI and the new Unity UI with the next release.



The yellow selection text comes from the Selector/ProximitySelector component. I'll assume ProximitySelector from the look of your screenshot. You can turn off the Unity GUI selection text by unticking Use Default GUI.



It looks like you might have already set up NGUI selection text in the lower left of your screenshot. If you need to tie this into the ProximitySelector, add a small script that hooks into the SelectedUsableObject and DeselectedUsableObject events. For example:

using UnityEngine;

using PixelCrushers.DialogueSystem;



public class NGUISelectionText : MonoBehaviour {



public ProximitySelector proximitySelector; // Assign this!

public UILabel label; // Assign this!

public UIWidget mainControl; // Assign this!



void OnEnable() {

proximitySelector.SelectedUsableObjectDelegate += OnSelectedUsable;

proximitySelector.DeselectedUsableObjectDelegate += OnDeselectedUsable;

}



void OnDisable() {

proximitySelector.SelectedUsableObjectDelegate -= OnSelectedUsable;

proximitySelector.DeselectedUsableObjectDelegate -= OnDeselectedUsable;

}



void OnSelectedUsable(Usable usable) {

NGUITools.SetActive(mainControl, true);

label.text = "Press chat icon to talk to " + usable.GetName();

}



void OnDeselectedUsable(Usable usable) {

NGUITools.SetActive(mainControl, false);

}

}



Save this as NGUISelectionText.cs, add it to a GameObject (the same as the ProximitySelector is a good choice), and assign proximitySelector, label, and mainControl. Label is the UILabel that current contains "Press chat icon to talk to Ted". MainControl is the NGUI control that contains the label, background images, etc., for the thing in the lower left of your screenshot.
andrew2110
Posts: 39
Joined: Wed Sep 03, 2014 2:44 am

ETA On NGUI Tutorials?

Post by andrew2110 »

Thanks for the reply! And sorry for my delay - I had "subscribed" to this post but must have missed the e-mail that notified me of a reply. I'll try to tie in the code you've given me today and look forward to the next video tutorials! Thanks again for an amazing piece of software :)
User avatar
Tony Li
Posts: 21056
Joined: Thu Jul 18, 2013 1:27 pm

ETA On NGUI Tutorials?

Post by Tony Li »

An updated NGUI support package is available for the Dialogue System. You can download it here or on the customer download site. If you need access to the site, please email your Asset Store invoice number to tony (at) pixelcrushers.com.



The updated package contains:



1. NGUI Selector Display component - which is an expanded and fully-tested version of the code above.



2. A fix to response buttons that was required by newer versions of NGUI.



3. Rebuilt basic dialogue UI prefabs that use NGUI's new prefab editing method.
andrew2110
Posts: 39
Joined: Wed Sep 03, 2014 2:44 am

ETA On NGUI Tutorials?

Post by andrew2110 »

I'm quite enjoying playing about with it now, it's all starting to come together.







http://www.blueomega.me/DialogueSystem1.mp4







This video shows a new problem I'm having. If I set "Button Alignment" to: ToFirst, I get one response showing. If I set it to "ToLast" I get the other response showing. What I really want is for both responses to be showing and to be able to deselect "Show unused buttons".
User avatar
Tony Li
Posts: 21056
Joined: Thu Jul 18, 2013 1:27 pm

ETA On NGUI Tutorials?

Post by Tony Li »

Your game's looking good! Nice, clean UI. That issue is really peculiar. I see that the console log says "Add Link" for both responses, so they should both be presented to the player. Do you perhaps have two copies of the UI, or are the button properties in the response menu section assigned to the wrong buttons?



If you haven't tried this already, try assigning the UI in the scene directly to the Dialogue Manager. The Dialogue Manager will use it instead of instantiating a prefab reference. It looks like this is how it's already configured; if not, give this a shot to get more information.



Also temporarily try one of the prefabs provided in the NGUI support package to narrow down the problem to the UI or somewhere else. If you haven't yet imported the patch listed above (NGUI_Support_2014-09-08.unitypackage), please do that, too.



If none of that helps, is it possible for you to send me a copy of your project? If it's too big for an email attachment, please contact me at tony (at) pixelcrushers.com so I can set up FTP access for you.
andrew2110
Posts: 39
Joined: Wed Sep 03, 2014 2:44 am

ETA On NGUI Tutorials?

Post by andrew2110 »

Ok so I don't fully understand why, but there seemed to be an issue with my regular game UI. When I moved all the objects in my regular UI to be children of the GUI camera object, the buttons started working as expected!



Thank you so much for your help!







A couple of extra things to report back:



I found that the TypewriterEffect class that comes with NGUI works great with Dialogue System, however it contained a bug which was fixed by adding:



<span style="font-family: Menlo;"><span style="color:#444444;">        </span><span style="color:#444444;">mNextChar</span><span style="color:#444444;"> = </span><span style="color:#f57c00;">0f</span><span style="color:#444444;">;</span></span>



To line 124. Otherwise the TypeWriter effect would only be used once.



Secondly and less importantly now for me - If instead of using a Dialogue Prefab from the project library, I used the UI currently in the hierarchy view, Dialogue System would create the default UI instead. Not a worry for me anymore though.
User avatar
Tony Li
Posts: 21056
Joined: Thu Jul 18, 2013 1:27 pm

ETA On NGUI Tutorials?

Post by Tony Li »

Hi,



Thanks for letting me know. I'll look into the dialogue prefab thing to make sure it's not a bug.



BTW, if you use "< pre>" and "</ pre>" tags around code in this forum software (bbPress), it will format it as code. I'll see if there's a plugin to make it a little more user-friendly.
andrew2110
Posts: 39
Joined: Wed Sep 03, 2014 2:44 am

ETA On NGUI Tutorials?

Post by andrew2110 »

Oh whoops! In the wysiwyg thing it was all nicely formatted, I clearly should have checked it again after posting! Sorry about that!
User avatar
Tony Li
Posts: 21056
Joined: Thu Jul 18, 2013 1:27 pm

ETA On NGUI Tutorials?

Post by Tony Li »

3105 wrote: Oh whoops! In the wysiwyg thing it was all nicely formatted, I clearly should have checked it again after posting! Sorry about that!


No problem. Sorry, turns out bbPress isn't the most user-friendly forum software. I'll keep an eye out for plugins to make it a little nicer, since it's a pain for me to work with, too. :-)
Post Reply