Search Unity

[RELEASED] Dialogue System for Unity - easy conversations, quests, and more!

Discussion in 'Assets and Asset Store' started by TonyLi, Oct 12, 2013.

  1. Stranger-Games

    Stranger-Games

    Joined:
    May 10, 2014
    Posts:
    393
    Hi,

    I now have the conversation log working correctly. However, I added my own typewriter effect to the log, so sometimes the choices appear before the effect is done. How can I prevent the choices from being called until the effect is done?

    Thanks for advance.
     
  2. TonyLi

    TonyLi

    Joined:
    Apr 10, 2012
    Posts:
    12,694
    Hi @Stranger-Games - The choices (or the next NPC line if that's what's next) appear when the dialogue entry's sequence is done. One solution is to make sure the sequence doesn't end until the typewriter effect is done. To do this:
    1. Add this sequencer command to your Sequence field (and/or the Dialogue Manager's Default Sequence):
      Code (sequencer):
      1. None()@Message(DoneTyping)
    2. When your typewriter effect is done, use this line of code:
      Code (csharp):
      1. Sequencer.Message("DoneTyping");
    The first step makes the sequence wait until it receives the sequencer message "DoneTyping", at which point it does nothing (the None() command) since the intent of this command is just to wait for the message. The second step sends that sequencer message.


    If you don't want to work with sequences, you could write an OnConversationLine() method. To do this:
    1. Add a Canvas Group to your response panel.
    2. In the OnConversationLine() method, set a bool to remember that the response menu should be visible. Then set the Canvas Group's alpha to 0, which will make the response menu invisible.
    3. When your typewriter effect is done, set the Canvas Group's alpha to 1 if the bool is true. Then set the bool false.
     
    Stranger-Games likes this.
  3. DecayGame

    DecayGame

    Joined:
    May 15, 2016
    Posts:
    86
    Wait so I can the the build of this?
     
  4. TonyLi

    TonyLi

    Joined:
    Apr 10, 2012
    Posts:
    12,694
    I'm not sure I understand, but yes, you can buy and play Heroes of Issachar on Steam Early Access. (Edit: Just now looking at the Steam page, it looks like the next availability to join Early Access is November 3, sorry.)

    Blue Mana Entertainment uses the Dialogue System for conversations, quests, etc. I don't know what they're using for the city-building part. It could be another Asset Store product, or they might have developed it in-house.
     
  5. DecayGame

    DecayGame

    Joined:
    May 15, 2016
    Posts:
    86
    Ohh, okay :3
     
  6. TonyLi

    TonyLi

    Joined:
    Apr 10, 2012
    Posts:
    12,694
    Dialogue System for Unity 1.6.6.4 Now Available!

    Version 1.6.6.4 is now available on the Asset Store and the Pixel Crushers customer download site.

    Version 1.6.6.4
    Core:
    • Added: OnConversationLineEnd script message; also added to Dialogue System Events component.
    • Improved: LoadLevel() sequencer command accepts optional spawnpoint.
    • Improved: AbstractConverterWindow template has new currentLineNumber and currentSourceLine utility properties.
    • Fixed: Bark priorities introduced in 1.6.6.3 were not being respected.
    • Fixed: A bug introduced in 1.6.6.3 caused dialogue UIs to ignore custom emphasis color settings.
    • Triggers:
      • Improved: Increment On Destroy can specify alert message duration; added OnIncrement() event.
      • Fixed: Rare NullReferenceException when bark triggers started.
    • Save System:
      • Improved: Added optional registration system to PersistentDataManager to optimize saving & loading.
      • Improved: Added PersistentDataManager.includeActorData/includeStatusAndRelationshipData properties.
      • Improved: Exposed PersistentDataManager settings in Dialogue Manager inspector.
      • Improved: PersistentDestructible now has choice between destroy and disable (deactivated).
      • Fixed: Some persistent data components would still save/load data even when they had been disabled.
    • Unity UI:
      • Exposed LocalizeUIText and UnityUIContinueButtonFastForward fields and methods for easier subclassing.
    • Save System:
      • PersistentPositionData now also looks for Actor[].Spawnpoint.
    • CSV Converter: Now reports the offending line and line number when it encounters an error.
    Third Party Support:
    • articy:draft:
      • Added a dropdown to specify whether to convert Slots as Display Name or Articy ID.
      • Fixed: Jumps to Conditions now correctly link to all specified entries, not just the first true condition entry.
    • S-Inventory/RFPS: S-Inventory Realistic FPS Prefab sub-package contains two improvements:
      • S-Inventory skill bar slot IDs have been assigned correctly.
      • Weapons (i.e., SInventory Weapon Pickups) can be assigned to the skill bar to be used with hotkeys.
    • TextMesh Pro:
      • Added improved typewriter effect.
      • Removed deprecation warning in Unity 5.3+.
    • UFPS:
      • Updated FP Persistent Player Data component to handle spawnpoints when changing levels.
     
    BackwoodsGaming likes this.
  7. Stranger-Games

    Stranger-Games

    Joined:
    May 10, 2014
    Posts:
    393
    Hi,

    Is there a way that I can make the player talk to himself? Like self-thoughts without the need for conversant?

    Thanks for advance and thanks for this great and amazingly flexible asset.
     
  8. Stranger-Games

    Stranger-Games

    Joined:
    May 10, 2014
    Posts:
    393
    Hi,

    Also is there a special character that I can insert inside a sentence to insert a pause that requires a click to continue like in visual novels?
    For example

    travelling made me exhausted.. and tired .. @, but I will not feel comfort until I am there

    In place of @ the typetext effect stops, then continues after the user clicks, or continues after a brief pause in automatic mode.

    Thanks for advance.
     
  9. TonyLi

    TonyLi

    Joined:
    Apr 10, 2012
    Posts:
    12,694
    Hi @Stranger-Games - In this case the conversation's actor and conversant will both be the player. To bypass the player response menu, create a second player actor in your dialogue database and set its "IsPlayer" field to False. (The player response menu is only shown for actors whose "IsPlayer" field is True.) Some developers name this actor "Player Monologue" or something like that to distinguish it from the regular Player actor. Then assign this as both participants in the conversation.

    If you're using Unity UI, the Typewriter Effect accepts a number of RPG Maker-style codes to control timing (for example, a full pause or a quarter pause), but not to force a click. For example:
    • Dialogue Text: "travelling made me exhausted \, and tired \., but I will not feel comfort until I am there"
    The typewriter will pause for a quarter second after "exhausted" and a full second after "tired".

    To force a click, split the line into two separate dialogue entry nodes and set the Dialogue Manager's Subtitle Settings > Continue Button mode to one of the settings that requires a continue button click, such as Always.
    • [1] Dialogue Text: "travelling made me exhausted \, and tired"

    • [2] Dialogue Text: "but I will not feel comfort until I am there"
     
  10. Stranger-Games

    Stranger-Games

    Joined:
    May 10, 2014
    Posts:
    393
    Thank you very much!
     
  11. Cartoon-Mania

    Cartoon-Mania

    Joined:
    Mar 23, 2015
    Posts:
    320
    Are there any news about Quest Maker?
     
  12. TonyLi

    TonyLi

    Joined:
    Apr 10, 2012
    Posts:
    12,694
    Thanks for asking! Beta testing should start the week after next. Unless the beta testers raise torches and pitchforks for a major change, the full release should follow fairly soon after.
     
    BackwoodsGaming and hopeful like this.
  13. Cartoon-Mania

    Cartoon-Mania

    Joined:
    Mar 23, 2015
    Posts:
    320
    Do you have plan to explain in detail about the Quest Maker?
     
  14. TonyLi

    TonyLi

    Joined:
    Apr 10, 2012
    Posts:
    12,694
    Yes. Next week I'll start a Quest Machine thread and post the link here. :)
     
    BackwoodsGaming likes this.
  15. Tilonsoft

    Tilonsoft

    Joined:
    Dec 2, 2015
    Posts:
    2
    Hi,

    May be there are some bug with the actors fields and localization. I added "Name es" as a localization field, but it doesn't appear next the Name and also if I fill it in the fields section, it doesn't display in the dialogue. I know it was a bug before but not sure if was fixed. Thanks!
     
  16. TonyLi

    TonyLi

    Joined:
    Apr 10, 2012
    Posts:
    12,694
    Hi @Tilonsoft - Names have to be handled a little differently because runtime conversations can use different actors than the actors defined in the conversation in the dialogue database. (See here if you want to read more about that.)

    The solution is to add an Override Actor Name component to the character's GameObject, and tick the Use Localized Name In Database checkbox. If the GameObject's name does not match the actor's name in the database, set the Override Name field to the actor's name in the database.

    Here's an example scene: LocalizedNamesExample_2016-09-26.unitypackage
     
    Tilonsoft likes this.
  17. TonyLi

    TonyLi

    Joined:
    Apr 10, 2012
    Posts:
    12,694
    A couple people asked about Lua recently. I thought I'd post here, too, to clarify.

    In the Dialogue System, working with Lua is entirely optional.

    Lua supports some really nice capabilities such as user-generated content; importing from Chat Mapper, articy:draft, Neverwinter Nights, and Excel; dynamic runtime code; and more that would be quite messy to do in other ways.

    But it's also an option that you can ignore if you prefer. It's merely another tool in the toolbox. On dialogue entry nodes, you can specify conditions using dropdown menus, and you can tie in your own activity to each node's On Execute () event in the same way you can tie activity to a UI Button's On Click () event. If you're a programmer and don't want to touch Lua, there are also a large number of script hooks for your own C# and UnityScript scripts.

    If anyone has questions about how to use Lua in the Dialogue System -- or how to not use Lua in the Dialogue System -- just let me know!
     
    BackwoodsGaming likes this.
  18. darrennorthcott

    darrennorthcott

    Joined:
    Jun 17, 2014
    Posts:
    20
    Hi,

    I'm using the S-Inventory Support Package, which is great. However, when I load a game, the equipped weapon is shown in the equipment slot, but the weapon itself isn't activated on the player... any idea how to fix this?

    Cheers!
     
  19. TonyLi

    TonyLi

    Joined:
    Apr 10, 2012
    Posts:
    12,694
    Hi @darrennorthcott - What kind of player are you using? Are you using Realistic FPS Prefab, another player control asset, or a custom player?

    In any case, since the Dialogue System's S-Inventory Support package handles loading and saving through the Dialogue System's save system, make sure Save and Load is unticked on your S-Inventory components.
     
  20. darrennorthcott

    darrennorthcott

    Joined:
    Jun 17, 2014
    Posts:
    20
    I'm using a basic 2D character, when save and load is ticked on s-inventorys equipment script, it will equip the weapon (activate the prefab) but (obviously) not save it properly. When unticked, it shows it in the equipment slot, but the prefab on the player is not activated.
     
  21. TonyLi

    TonyLi

    Joined:
    Apr 10, 2012
    Posts:
    12,694
    Activating prefabs on the player was a later feature introduced in S-Inventory that the Dialogue System's third party support package wasn't observing yet. Sorry about the oversight. Here's a patch to add that feature:

    SInventory_Support_Patch_2016-10-03.unitypackage

    The update will be included in the next full release of the Dialogue System, too. It's a simple one line addition to SInventoryDialogueActor.cs line 250:
    Code (csharp):
    1.     slot.Icon.sprite = item.Icon;
    2.     equipment.ActivateEqObj(item.Name); //<-- ADD THIS LINE.
    3. }
    If you import the patch, you don't need to do anything else (i.e., don't need to manually edit SInventoryDialogueActor.cs or anything like that).
     
  22. darrennorthcott

    darrennorthcott

    Joined:
    Jun 17, 2014
    Posts:
    20
    Worked like a charm! Thank you!!
     
  23. TonyLi

    TonyLi

    Joined:
    Apr 10, 2012
    Posts:
    12,694
    Happy to help!
     
  24. Stranger-Games

    Stranger-Games

    Joined:
    May 10, 2014
    Posts:
    393
    Hi,

    I am using the WaitForMessage sequencer command, because I want to pause the conversation until an event is fired, but I noticed if I press the continue button, the conversation will continue regardless. I tried this code on a certain conversation code, and I never call the OnSequencerMessage message, but still pressing the continue button continues the conversation.

    Code (CSharp):
    1. WaitForMessage(never);
    Thanks for advance.
     
  25. TonyLi

    TonyLi

    Joined:
    Apr 10, 2012
    Posts:
    12,694
    Hi @Stranger-Games - That's by design. If you want to temporarily disable the continue button, use this sequence:

    SetContinueMode(false);
    WaitForMessage(myEvent);
    SetContinueMode(true)@Message(myEvent)
    • The first command (SetContinueMode(false)) turns off the continue button.
    • The second command (WaitForMessage(myEvent)) waits for your event.
    • The third command (SetContinueMode(true)@Message(myEvent)) also waits for your event and then turns the continue button back on.
    So in this case you can actually omit WaitForMessage because the last command will also wait. You can simplify the sequence to:

    SetContinueMode(false);
    SetContinueMode(true)@Message(myEvent)
     
    Stranger-Games likes this.
  26. Stranger-Games

    Stranger-Games

    Joined:
    May 10, 2014
    Posts:
    393
    I think I got the grasp now for what it means.
    I tried the following which also seems to give the same effect.

    SetContinueMode(false);
    WaitForMessage(myEvent);
    SetContinueMode(true);

    Thanks!
     
  27. Stranger-Games

    Stranger-Games

    Joined:
    May 10, 2014
    Posts:
    393
    I noticed that there is a convenient Actor.AssignedField("SomeFiled").typeString
    But there is no equivalent for DialogueEntry.
    I had to do this, is there a better way, or is the way I am using, the best?

    Code (CSharp):
    1. subtitle.dialogueEntry.fields.Find(s => s.title == "Active Fields Index");
    Thank you always for your great support.
     
  28. TonyLi

    TonyLi

    Joined:
    Apr 10, 2012
    Posts:
    12,694
    You'll definitely want to include the "@Message(myEvent)" part in SetContinueMode(true)@Message(myEvent).

    Every sequencer command tries to run immediately (that is, at time mark 0) unless you specify a time with the "@" symbol such as:

    Audio(Explosion)@2; Play Explosion audio clip at 2.0 second mark.
    Animation(Fall)@Message(Hit); Play Fall animation clip at message "Hit".
    What's probably happening in your example is that SetContinueMode(false) and SetContinueMode(true) are running at the same time, and one of them "wins". But you can't guarantee which one will win every time, so it's best to use the "@" syntax.
     
    Stranger-Games likes this.
  29. TonyLi

    TonyLi

    Joined:
    Apr 10, 2012
    Posts:
    12,694
    You can also use the static function Field.LookupValue:

    Code (csharp):
    1. var myVariable = Field.LookupValue(subtitle.dialogueEntry.fields, "Active Fields Index");
    If you want to get the field as an integer, use LookupInt, etc.
     
  30. Stranger-Games

    Stranger-Games

    Joined:
    May 10, 2014
    Posts:
    393
    Thanks for the precious information!

    Thank you, you saved me a lot of hair pulling :D
     
  31. TonyLi

    TonyLi

    Joined:
    Apr 10, 2012
    Posts:
    12,694
    Glad to help!
     
    Stranger-Games likes this.
  32. blamejane

    blamejane

    Joined:
    Jul 8, 2013
    Posts:
    233
    I'm creating a new Unity IOS/Android project and will be adding cutscenes to my game. There is no dialog as this just a simple driving game. I was curious if you thought your asset was lightweight enough for my needs, especially considering I'm not going to have "dialog". Or do you think it might be a little overkill? I am proficient in C# so that's not a consideration, just didn't want to waste my time. I figured I'd check with the experts here.

    Thanks,

    Valerie
     
  33. TonyLi

    TonyLi

    Joined:
    Apr 10, 2012
    Posts:
    12,694
    Hi Valerie - If you're not using dialogue, I recommend using a dedicated cutscene editor such as SLATE. I hope you keep the Dialogue System in mind if your next project has dialogue. :)
     
  34. blamejane

    blamejane

    Joined:
    Jul 8, 2013
    Posts:
    233
    Thanks for the recommendation. I do already own your asset, just have yet to need it : )
    I will look into Slate.
     
    TonyLi likes this.
  35. quesadillas

    quesadillas

    Joined:
    May 1, 2015
    Posts:
    23
    Hey Tony! So, I went back to look at the bug I had where the player's lines cut off whenever they move, and I figured out where the conflict is. I'm using UFPS in the game as well, and it has a Surface Manager system that does things like playing the sounds of footsteps. I didn't add an Audio Source to each foot, so the Surface Manager automatically goes up the hierarchy and uses the first audio source it could find, which was the same one the dialogue system was using. Once I added those audio sources, all the audio played normally. :]
     
    hopeful likes this.
  36. TonyLi

    TonyLi

    Joined:
    Apr 10, 2012
    Posts:
    12,694
    Wow, that was an obscure one! Glad you got it straightened out.
     
  37. TonyLi

    TonyLi

    Joined:
    Apr 10, 2012
    Posts:
    12,694
    Updated Adventure Creator Support Package Available

    The Dialogue System Extras page has an updated support package for Adventure Creator that implement some really useful customer requests:
    • The Third Party: Dialogue System Conversation action now has a 'Wait until finish?' checkbox to specify whether to halt the actionlist until the conversation ends or just start the conversation and let the actionlist keep running while the conversation is active.
    • This action also has new options so you can override the bridge settings (Use Dialog State and Take Camera Control) on a per-conversation basis if you want.


    A core patch on the customer download page is also available. If you'd like access, please PM me your Asset Store invoice number. These changes will also be in the next full release:
    • Changed: OnSequenceStart and OnSequenceEnd messages are now also sent to the Dialogue Manager, not just the participants. (To receive messages during conversations, you must still tick the Dialogue Manager’s Subtitle Settings > Inform Sequence Start And End checkbox.)
    • Fixed: Bark triggers now don’t report NullReferenceException if destroyed before being initialized.
    • Added: LevelManager.LoadLevel(index) to load by build scene index.
    • Improved: LevelManager.RestartGame/GameSaver.RestartGame now automatically update quest tracker HUD.
    • articy:draft: Fixed: Convert Slots As dropdown wasn’t saving selection when window closed.
    • Chat Mapper: Chat Mapper Converter now handles Chat Mapper fields of type "Multiline".
    • Unity UI:
      • UnityUITypewriterEffect: Now handles <quad> rich text code, right-to-left support (Arabic).
      • Subtitle text, portrait name, and response button text now send OnTextChanged(UnityEngine.UI.Text) message to dialogue UI.
     
    Deckard_89 likes this.
  38. TonyLi

    TonyLi

    Joined:
    Apr 10, 2012
    Posts:
    12,694
    Dialogue System for Unity 1.6.6.5 Released!

    Version 1.6.6.5 is now available on the Pixel Crushers customer download site (PM me your Asset Store invoice number if you need access) and should be available on the Asset Store in 5-7 days, possibly a little longer since Unity staff are also busy getting ready for the Unite conference.

    Some highlights of this release:
    • Dialogue Editor: You can now specify which custom fields to show in the main part of the inspector instead of just in the All Fields foldout.
    • Unity UI typewriter effect: Now handles <quad> rich text codes and left-to-right (e.g., Arabic) text.
    • Adventure Creator "Dialogue System Conversation" action has more options to give you greater control of how conversations mesh with Adventure Creator.

    Version 1.6.6.5
    Core

    • Changed: OnSequenceStart & OnSequenceEnd messages are now also sent to Dialogue Manager, not just participants.
    • Improved: LevelManager.RestartGame/GameSaver.RestartGame now automatically update quest tracker HUD.
    • Added: LevelManager.LoadLevel(index) to load by build scene index.
    • Fixed: Bark triggers now don't report NullReferenceException if destroyed before being initialized.
    • Dialogue Editor:
      • Added: Checkboxes in template to show specific custom fields in main part of inspector.
      • Added: Menu option to automatically split nodes with pipes ( | ) in text into separate nodes.
      • Improved: Watches tab > Watch Variable now lets you choose active variable, not just variables defined in dialogue database.
      • Improved: Added confirmation window when attempting to delete special "Is Item" field.
    • Unity UI:
      • Improved: UnityUITypewriterEffect now handles <quad> rich text code, right-to-left support (Arabic).
      • Improved: Subtitle text, portrait name, and response button text now send OnTextChanged(UnityEngine.UI.Text) message to dialogue UI.
      • Changed: When instantiating response buttons from template, instance names now match response button text.
      • Fixed: If alert line had no panel, alert line didn't disappear.
    Third Party Support
    • articy:draft: Fixed: Convert Slots As dropdown wasn't saving selection when window closed; in Unity 5.4+ articy converter window now correctly saves settings changes when exiting Unity while converter window is open and docked.
    • Adventure Creator: Added to Conversation action: "Wait until finish?" checkbox, Override Bridge UseDialogState and TakeCameraControl settings.
    • Chat Mapper: Updated to handle Chat Mapper fields of new type "Multiline".
    • PlayMaker: Added Pause/Unpause actions; updated LoadLevel action to prevent API warnings in Unity 5.3+.
     
    Corvwyn likes this.
  39. Stranger-Games

    Stranger-Games

    Joined:
    May 10, 2014
    Posts:
    393
    Hi,

    Is there a slot functionality for the built in saving/loading?

    Thanks for advance.
     
  40. Stranger-Games

    Stranger-Games

    Joined:
    May 10, 2014
    Posts:
    393
    My bad GameSaver.SaveGame does have a slot parameter.
     
  41. TonyLi

    TonyLi

    Joined:
    Apr 10, 2012
    Posts:
    12,694
    BTW, if you want even more functionality, please take a look at the free menu framework add-on available on the Dialogue System Extras page. It gives you a complete UI for managing saved game slots, pause menu, options menu, etc.
     
    Stranger-Games likes this.
  42. TonyLi

    TonyLi

    Joined:
    Apr 10, 2012
    Posts:
    12,694
  43. antoripa

    antoripa

    Joined:
    Oct 19, 2015
    Posts:
    1,163
    Hi,
    I downloaded and test demo version. It is really nice tool, but my concern is that I have not seen only GUI items.
    does your tool support UGUI or just GUI ? Thanks
     
  44. TonyLi

    TonyLi

    Joined:
    Apr 10, 2012
    Posts:
    12,694
    Hi @antoripa - Yes, it supports Unity UI (UGUI), as well as legacy Unity GUI, NGUI, TK2D, DF-GUI, TextMesh Pro, etc. The Feature Demo scene uses legacy Unity GUI, but there's also an equivalent version in the "Examples/Unity UI Examples" folder that uses Unity UI along with some others such as one that uses world space UIs (overhead speech bubbles). Primary development is done with Unity UI first now, and you can find other examples of using Unity UI on the Dialogue System Extras page, in the UIs section.

    The Dialogue System is GUI independent. It will work happily with any UI that implements a simple C# IDialogueUI interface. It ships with implementations for all the GUI systems above. In their own projects other developers have written IDialogueUI implementations for different applications such as text-to-speech plus voice recognition for vision-impaired users, and gesture-sensing interfaces for immersive VR "cave" installations.
     
    TeagansDad and antoripa like this.
  45. antoripa

    antoripa

    Joined:
    Oct 19, 2015
    Posts:
    1,163
    Thanks. I am even exploting text to speech integration. Can you provide me information about tools used with your pakcage ?
     
  46. TonyLi

    TonyLi

    Joined:
    Apr 10, 2012
    Posts:
    12,694
    Hi @antoripa - There's an RT-Voice integration package in Third Party Support. RT-Voice is a very good text-to-speech asset. If you instead want to do lipsync with pre-recorded voice actors, you have several options, including SALSA, LipSync Pro, FaceFX, and others. These integrations generally use sequences, which are instructions associated with each dialogue entry node. The RT-Voice integration doesn't need a sequence; it just intercepts subtitles and plays them through RT-Voice's text-to-speech functionality.
     
    antoripa likes this.
  47. TonyLi

    TonyLi

    Joined:
    Apr 10, 2012
    Posts:
    12,694
    Last edited: Oct 27, 2016
  48. TonyLi

    TonyLi

    Joined:
    Apr 10, 2012
    Posts:
    12,694
    Updated Support Packages for S-Inventory + RFPS, TextMesh Pro, and Opsive's Third Person Controller

    The Dialogue System Extras page has updated support packages for:
    • S-Inventory + Realistic FPS Prefab: Fixes weapon equipping/pickup bugs; adds consumeSound field to consumable pickups.
    • TextMesh Pro: Removes an API deprecation warning in Unity 5.3+.
    • Third Person Controller: Adds a new sequencer command TPCAbility() to run a TPC ability in a cutscene sequence.
    These updated packages will also be in the next release of the Dialogue System.
     
    Deckard_89 likes this.
  49. HeyItsLollie

    HeyItsLollie

    Joined:
    May 16, 2015
    Posts:
    68
    Hi ToniLi,
    I've been making my panel from scratch using UnityUI, and I need it to be exclusively navigable with key/button inputs (I'm aiming for console-style JRPG). It mostly does everything I want on its own (which is awesome), but I've run into a couple odd issues.

    Pressing Enter while using Fast-Forward + UI Button Key Trigger causes input to occur twice.
    The dialogue text uses the typewriter effect, and the continue button uses the fast-forward script and the required OnClick event. Because my setup will need key-exclusive inputs, I've added a UI Button Key Trigger as a failsafe (any mouse input removes focus from the continue button).

    With this setup, using the main Return key (or space bar) causes the Click event to occur twice. Pressing Return during the typewriter animation causes the dialogue to advance to the next node. Pressing Return after the animation has completed causes following nodes to automatically skip the animation.

    It's worth noting that this doesn't happen while using the Numpad Return key, keys like Ctrl or letters/numbers, or if the UI Button Key Trigger is disabled (it's clear this is causing conflicts, but I'd prefer to have a failsafe handy).
    __

    The continue button doesn't close the dialogue panel on the final node of a conversation. The only way to close the panel is to wait 20-30 seconds. This one has me stumped, because I know it was working properly earlier on, and I haven't made any drastic changes to the continue button in my setup. I'm assuming I'm overlooking something, because I don't run into this issue with any of the provided UnityUI prefabs.
    edit: Figured this one out! I simply had two stray animation triggers in the UnityUI Dialogue UI script. I don't have any animations set up for the dialogue panels, so the UI hangs at the end while it waits for animations that don't exist.

    I've attached a barebones test scene that should demonstrate both issues, just add 1.6.6.5 before opening the included scene.
     

    Attached Files:

    Last edited: Oct 30, 2016
  50. TonyLi

    TonyLi

    Joined:
    Apr 10, 2012
    Posts:
    12,694
    Hi @3noneTwo - Use the script below instead of UI Button Key Trigger. It's also in this updated package:

    20161030_ContinueIssues_StayFocused.unitypackage

    Here's why:

    The Unity UI Dialogue UI uses Unity's Event System. By default, the Event System's Submit Button is mapped to the Unity Input Manager's Submit button definition, which is mapped to the return and space keys. When you press the main Return key or space bar, the Event System clicks the currently-focused UI element. But the UI Button Key Trigger also detects the input and also clicks the UI element, so it gets clicked twice.

    The solution is to remove the UI Button Key Trigger and, instead, add a script to the ContinueNub and response buttons that keeps them focused. The script below does that. The script has a Priority field that you can set to specify which button should regain focus if the player uses the mouse to remove focus. The ContinueNub has priority 0, and the response buttons have priority 1 because they should take priority over the ContinueNub if they're visible.

    StayFocused.cs
    Code (csharp):
    1. using UnityEngine;
    2. using UnityEngine.EventSystems;
    3. using System.Collections.Generic;
    4. using System.Linq;
    5.  
    6. public class StayFocused : MonoBehaviour
    7. {
    8.  
    9.     public int priority;
    10.  
    11.     private UnityEngine.UI.Selectable m_selectable;
    12.  
    13.     private static List<StayFocused> s_selectables = new List<StayFocused>();
    14.  
    15.     void Awake()
    16.     {
    17.         m_selectable = GetComponent<UnityEngine.UI.Selectable>();
    18.         if (m_selectable == null) enabled = false;
    19.     }
    20.  
    21.     void OnEnable()
    22.     {
    23.         s_selectables.Add(this);
    24.         s_selectables.OrderBy(x => x.priority);
    25.     }
    26.  
    27.     void OnDisable()
    28.     {
    29.         s_selectables.Remove(this);
    30.     }
    31.  
    32.     void Update()
    33.     {
    34.         if (EventSystem.current.currentSelectedGameObject == null && s_selectables[s_selectables.Count - 1] == this)
    35.         {
    36.             EventSystem.current.SetSelectedGameObject(this.gameObject);
    37.         }
    38.     }
    39. }

    You beat me to it. :) When you have animation triggers, the dialogue UI sets the trigger and waits for the animator to transition. Since no animations are set up, the animator never transitions. There's a built-in safeguard that will stop waiting after 10 seconds (which I know feels like 20-30 seconds -- or more like 20-30 minutes -- when you're sitting there waiting for something to happen).
     
    HeyItsLollie likes this.