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. TonyLi

    TonyLi

    Joined:
    Apr 10, 2012
    Posts:
    12,694
    Hi @vivalavida - In the upcoming version 1.5.9 (coming out Monday), if you add an Override Actor Name component it will also let you specify the portrait image. In your case, you'll only need to add an Override Actor Name to each character, and the portraits should work like you describe.

    Hi @Ludo97 - Here are two ideas:

    1. Set the Audio Source's Spatial Blend to 3D. (Move the slider all the way to the right.) Position the Audio Source in the ocean at the edge of the beach. When the player is close to the ocean, the sound will be loud. As the player moves away from the ocean, the sound will get quieter.

    2. Or put an invisible trigger collider on the beach. (For example, add a Cube GameObject. Resize the cube so it covers the beach. Then turn off its MeshRenderer and tick Is Trigger on its BoxCollider.) Add a Range Trigger to it. Set Condition > Accepted Tags to "Player". Set the GameObjects section to activate the ocean sound Audio Source.
     
    vivalavida likes this.
  2. Ludo97

    Ludo97

    Joined:
    Dec 9, 2015
    Posts:
    121
    Thank you
     
  3. flashframe

    flashframe

    Joined:
    Feb 10, 2015
    Posts:
    797
    Hey, I’m starting to integrate Dialogue System into our game and have a few questions that the docs haven’t fully cleared up for me. It’s clearly a great asset and is a far superior dialogue solution than I could have built myself, but as with a lot of third party assets there are lots of features I don’t need and I’m trying to work out the best way to use it without having redundancies or duplicating functionality, and making it easy to manage everything.

    More detailed examples:

    1. If I don’t intend to use features of the Dialogue System, like Quests, will they still be compiled as part of my game? Do these unused features represents a significant bloat to the game or are they nothing to worry about?

    2. I have already built my own variables manager that I’m happy with and using throughout my project. I’d like to use this instead of the Dialogue System variables. Are there any risks/caveats I should be aware of before going down this route?

    3. Localisation. Can I extend the localisation functionality of DS to also maintain localisations of other text in my game?

    4. Save System. Likewise, can I extend the Dialogue System save system to save all other aspects of my game? Can I use the Lua environment to save my own custom classes and data? Is this recommended or would you keep the Dialogue System functionality separate? What I’m getting at really is that I’m not keen on having lots of separate systems in the game that are performing the same functionality. So since there is a save system built into Dialogue System, I’m wondering if it is best to extend it to save all data. Can you point me in the right direction of how to do this if you think it’s not a terrible idea?

    My inclination is to try to get everything using the same systems, but maybe this is the wrong approach. Is it just to plugin in the Dialogue System and let it do it’s own thing and create my own solutions for everything else?

    Final final question: Has the Dialogue System been tested on PS4?

    Sorry for the long post! And thanks for any assistance you can provide!
     
  4. TonyLi

    TonyLi

    Joined:
    Apr 10, 2012
    Posts:
    12,694
    Hi @flashframe - They're nothing to worry about. The entire runtime DLL is 314 KB, which is smaller than a typical small texture file.

    The only caveat is that you won't be able to use the Lua wizard dropdown menu to select variable names when specifying Conditions and Scripts on your conversation nodes.

    You can still register Lua functions that get and set variables in your variable manager. You can then use these Lua functions in the Conditions and Scripts fields on your conversation nodes. The third party integration packages do this to expose variables such as UFPS's health and ammo, Adventure Creator's variable manager, etc.

    Yes. The Dialogue System includes general-purpose localized text tables. The Dialogue System uses them to localize UI elements such as continue buttons on subtitle panels, but you can use them for any other purpose, too.

    The Dialogue System's save system is best for simple data types (bool, int, float, string), not structured data (except for the Dialogue System's own internal structured data). If you use the Dialogue System's save system for structured data, you'll want to save select primitive values, like how Persistent Position Data saves position and rotation as a set of floats.

    If you want to serialize an entire class, on the other hand, use a dedicated save system plugin such as Easy Save. In this case, think of the Dialogue System's save system as a serializer for Dialogue System data. It serializes all Dialogue System data as a string that you can then save with Easy Save. The Dialogue System Extras page has an example scene that uses Easy Save and PlayMaker.

    I agree with your inclination. I'm a fan of DRY -- Don't Repeat Yourself. The Dialogue System gives you the tools to work with your own variables and manage localization. There's no need to implement redundant systems there. Many games also use the Dialogue System as a standalone save system. But if your game requires a more complex save system, the Dialogue System's save system is designed so you can just treat it as a data source for other save systems.

    I haven't tested it; I don't know if other developers have. It runs on PS3 and PS Vita, and I'm not aware of anything in the codebase that would cause problems with PS4.
     
  5. flashframe

    flashframe

    Joined:
    Feb 10, 2015
    Posts:
    797
    @TonyLi

    Thank you for such a detailed and reassuring response. It's funny how just thinking about the save system as a serializer makes it clearer for me!

    Localisation for other text is awesome, thanks for pointing out the right place in the docs!

    And I will have a look at the third party examples to see how I might expose my custom variables to the dialogue system.

    Thanks again, you've really helped clear this up for me!
     
  6. TonyLi

    TonyLi

    Joined:
    Apr 10, 2012
    Posts:
    12,694
  7. TonyLi

    TonyLi

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

    Version 1.5.9 is now available on the Pixel Crushers customer download site! (PM me your Asset Store invoice number if you'd like access.) It should be available on the Asset Store in a few days.

    NOTE: The 35% Off New Year Sale ends when version 1.5.9 arrives on the Asset Store!


    I'm really excited about some handy new features in this version. Some of them are:
    • Conversation-specific overrides. You can now set subtitle behavior, default sequences, timeout values, and more in the Dialogue Editor without having to use an Override Display Settings component.
    • You can now use [lua(...)] and [var=varName] markup in sequences. This adds a lot of new power and flexibility to sequences.
    • Other Dialogue Editor improvements: You can now append fields with the Lua wizard. There's a new button to quickly swap the speaker and listener in a dialogue entry node. The quest editor has a Use Group checkbox to make it easier to organize quests into groups.
    • Added RPGMaker-style timing commands to the Unity UI Typewriter Effect. For example, use "\," to pause 1/4 second, "\." to pause 1 second, "\^" to instantly finish the rest of the text, etc.
    • Runtime articy:draft importer: You can now import articy:draft data at runtime! (Runtime Chat Mapper import was already supported.) This provides another option for adding modding support to your games.
    These were all feature requests from the community. Thanks for the great suggestions!


    Here are the complete release notes:

    Version 1.5.9
    Core
    • Changed: All triggers that are set to OnDestroy now respect LevelManager's OnLevelWillBeUnloaded message and won't fire in this case.
    • Changed: Audio/AudioWait sequencer commands no longer set AudioSources with volume=0 to volume=1.
    • Changed: For Windows Store/Phone compatibility, UTF7 & Default encoding is now Unicode, ASCII encoding is now UTF8.
    • Changed: Refactored several editor classes to support runtime articy:draft imports.
    • Added: Can now import articy:draft projects at runtime.
    • Added: Lua SetQuestState() and SetQuestEntryState() functions.
    • Added: OnQuestStateChanged message when quest states change.
    • Added: OnLinkedConversationStart when an active conversation links to another conversation.
    • Improved: Can now use [lua] & [var] markup tags in sequences.
    • Improved: Uses correct portrait picture according to participant's GameObject name or OverrideActorName component.
    • Improved: GameSaver searches scene for a LevelManager if it doesn’t have one as a child.
    • Fixed: Trigger editors weren’t saving changes made to instances of prefabs in some versions of Unity.
    • Fixed: [ConversationPopup] attribute with non-default database now shows correct conversation in playmode.
    • Dialogue Editor:
      • Added: Optional conversation-specific overrides for subtitle behavior, default sequences, etc.
      • Added: Button to quickly swap a dialogue entry node's speaker & listener.
      • Added: Use Group checkbox to Quest tab.
      • Improved: Lua wizards: Added option to append existing field; now applies automtically if you move away; added SimStatus & Custom dropdowns.
      • Fixed: Can now select cross-conversation links to group nodes or nodes without dialogue text.
      • Fixed: Sync Actors now syncs alternate portrait images.
    • Unity UI:
      • Improved: Typewriter effect timing codes added; improved rich text code support; automatically enables rich text support if needed.
      • Fixed: Removed duplicate typewriter effect from JRPG Dialogue UI prefab.
    Third Party Support
    • Adventure Creator: Added component to fit UIs to forced aspect ratios.
    • Makinom: Show Alert node now uses Makinom string value, not a string literal.
    • ORK Framework: Run Lua action can now specify return value type.
    • Realistic FPS Prefab: Conversation handler prevents VisibleBody from animating body & CameraKick from bobbing camera.
    • Rogo LipSync: Updated for 0.5 compatibility.
    • RPG Kit: Made playerInventoryGameObjectName editable in RPGKitBridge; quest log window no longer hides cursor when closing by pressing Escape.
    • SALSA with RandomEyes: Updated for SALSA 1.4 compatibility; added support for RandomEyes shape groups.
    • Third Person Controller: Updated for Third Person Controller 1.2 compatibility.
     
    SuperNewbee and flashframe like this.
  8. flashframe

    flashframe

    Joined:
    Feb 10, 2015
    Posts:
    797
    @TonyLi

    One more question sorry!

    Is there a way to group or filter conversations in the Dialogue window? I can see that the dropdown list is going to get very long very quickly.
     
  9. TonyLi

    TonyLi

    Joined:
    Apr 10, 2012
    Posts:
    12,694
    Hi @flashframe - Put forward slashes in your conversation titles. For example:
    • The Shire/Birthday Speech
    • The Shire/Gandalf's Warning
    • The Shire/Ain't Been Dropping No Eaves
    • Moria/Friend
    • Moria/Balrog
    • Rohan/Edoras/Wormtongue
    The forward slashes will group them into submenus. You can go as many levels deep as you want. (Then again, careful not to go too greedily or too deep. Might run into a Balrog. ;))
     
  10. flashframe

    flashframe

    Joined:
    Feb 10, 2015
    Posts:
    797
    Ha ha! Perfect, exactly what I needed, thank you!
     
  11. TonyLi

    TonyLi

    Joined:
    Apr 10, 2012
    Posts:
    12,694
    Version 1.5.9 is now available on the Asset Store!

    Release notes are above.
     
    hopeful likes this.
  12. kebrus

    kebrus

    Joined:
    Oct 10, 2011
    Posts:
    415
    Quick question, how could I disable the reminder NPC panel and only in some dialogue entries activate it or vice-versa, being always on and only in some entry disable it?
     
  13. TonyLi

    TonyLi

    Joined:
    Apr 10, 2012
    Posts:
    12,694
    Hi @kebrus - Here are some ideas:

    1. Leave it on by default. In dialogue entries where you want it hidden, add this sequencer command to the Sequence field:
    Code (sequencer):
    1. SetActive(NPC Subtitle Panel, false)
    (Replace "NPC Subtitle Panel" with the appropriate GameObject name if you've renamed it.)


    2. Define a custom field in your dialogue entries, perhaps a Boolean named "PanelVisible". Make a subclass of your dialogue UI (e.g., UnityUIDialogueUI) and override ShowSubtitle. Something like:
    Code (csharp):
    1. public MyDialogueUI : UnityUIDialogueUI {
    2.     public override void ShowSubtitle(Subtitle subtitle) {
    3.         if (Field.LookupBool(subtitle.dialogueEntry.fields, "PanelVisible")) base.ShowSubtitle(subtitle);
    4.     }
    5. }
     
    kebrus likes this.
  14. Ludo97

    Ludo97

    Joined:
    Dec 9, 2015
    Posts:
    121
    Hello , how to put markers where there is a quests for the player to be spotted ? thank you
     
  15. TonyLi

    TonyLi

    Joined:
    Apr 10, 2012
    Posts:
    12,694
    Hi @Ludo97 - The Dialogue System comes with third party integration for HUD Waypoint support, KGFMapSystem support, and NJG MiniMap support. In each of those, you can use a sequencer command, such as NJGMapItem() for NJG MiniMap, to show, hide, and change map icons or waypoint markers.

    You can also use the SetActive() sequencer command to activate and deactivate marker GameObjects. For example, say you've add a GameObject named "Quest Marker" to the wizard Usidore and made the GameObject inactive. To activate the marker, use this sequencer command:
    Code (sequencer):
    1. SetActive(Usidore/Quest Marker)
     
  16. Ludo97

    Ludo97

    Joined:
    Dec 9, 2015
    Posts:
    121
    Thank you , by any chance it is possible to integrate with cinematics ?
     
  17. TonyLi

    TonyLi

    Joined:
    Apr 10, 2012
    Posts:
    12,694
    Yes, the Dialogue System has uSequencer support, Cinema Director support, and Animator Timeline Editor support. You can build your cinematics in any of these cinematic editors. Then link it to a dialogue entry node by adding a command such as uSeq(MySequence) to the Sequence field.
     
  18. Ludo97

    Ludo97

    Joined:
    Dec 9, 2015
    Posts:
    121
    If the drive is already made video ( on a 3D software) it is possible to integrate the video ? as in GTA , cinematic video before and after starting the quests .
     
  19. TonyLi

    TonyLi

    Joined:
    Apr 10, 2012
    Posts:
    12,694
    Yes, sure, it depends on how you want to play it.

    If you're playing the video on a texture, you can use the SetActive() sequencer command to activate and deactivate the texture.

    If the video is in a separate scene, you can use the LoadLevel() sequencer command to load the scene.

    You can also write a small script that uses the script message "OnQuestStateChange". For example:
    Code (csharp):
    1. public ShowQuestVideos : MonoBehaviour { // Add to Dialogue Manager.
    2.  
    3.     public void OnQuestStateChange(string questTitle) {
    4.         var questState = QuestLog.GetQuestState(questTitle);
    5.         // Show the appropriate video for questTitle and questState.
    6.         // For example (assuming you have a method named ShowVideo):
    7.         if (string.Equals(questTitle, "Steal the Car")) {
    8.             if (questState == QuestState.Active) {
    9.                 ShowVideo("Steal the Car Starting Video");
    10.             } else if (questState == QuestState.Success) {
    11.                 ShowVideo("Steal the Car Ending Video");
    12.             }
    13.         }
    14.     }
    15. }
     
  20. TonyLi

    TonyLi

    Joined:
    Apr 10, 2012
    Posts:
    12,694
    Visual Novel Framework, Dialogue System Patch Available


    Visual Novel Framework

    The Dialogue System Extras page now has a visual novel framework. If you're making a visual novel with the Dialogue System and have any questions about using the framework, please post here or drop me a line at tony (at) pixelcrushers.com!


    Patch 2016-02-07

    A small patch is available on the Pixel Crushers customer download site. (PM me your invoice number if you'd like access.) Apart from a few superficial items, it contains some additions for Localized Text Tables:
    • You can now specify the encoding type (UTF8 or Unicode) to use when importing/exporting to CSV format.
    • Added LocalizeUIText.UpdateFieldName() method.
     
  21. Ludo97

    Ludo97

    Joined:
    Dec 9, 2015
    Posts:
    121
    Really thank you , I managed to create a scenario Dialogue System and it's very powerful tools that , really thank you for this wonderful tool . This is very good work
     
  22. TonyLi

    TonyLi

    Joined:
    Apr 10, 2012
    Posts:
    12,694
    Thanks! Have fun making your game!
     
  23. Ludo97

    Ludo97

    Joined:
    Dec 9, 2015
    Posts:
    121
    1. public ShowQuestVideos : MonoBehaviour { // Add to Dialogue Manager.

    2. public void OnQuestStateChange(string questTitle) {
    3. var questState = QuestLog.GetQuestState(questTitle);
    4. // Show the appropriate video for questTitle and questState.
    5. // For example (assuming you have a method named ShowVideo):
    6. if (string.Equals(questTitle, "Steal the Car")) {
    7. if (questState == QuestState.Active) {
    8. ShowVideo("Steal the Car Starting Video");
    9. } else if (questState == QuestState.Success) {
    10. ShowVideo("Steal the Car Ending Video");
    11. }
    12. }
    13. }
    14. }
    I took this script in the editor but he said:
     

    Attached Files:

  24. TonyLi

    TonyLi

    Joined:
    Apr 10, 2012
    Posts:
    12,694
    Hi @Ludo97 - Sorry for being unclear. My previous reply was pseudo-code, not real code. I just wanted to show you the basic idea.

    To fix the errors 'QuestLog does not exist in the current context' and 'QuestState does not exist in the current context', add this line to the using statements at the top of your script:
    Code (csharp):
    1. using UnityEngine;
    2. using System.Collections;
    3. using PixelCrushers.DialogueSystem; //<-- ADD THIS LINE.
    The method 'ShowVideo' is not a real method. It's a fake placeholder to indicate that you should play the video however you need to.

    For one example, let's say you've prepared several Movie Textures and added them as Raw Images to your Unity UI Canvas. Set them all inactive for now so the player can't see them when the game starts. Name the Raw Image GameObjects with names like "Steal the Car Starting Video" so you can call:
    Code (csharp):
    1. ShowVideo("Steal the Car Starting Video");
    The ShowVideo method might look something like this:
    Code (csharp):
    1. void ShowVideo(string rawImageGameObjectName) {
    2.     // This method also finds inactive GameObjects:
    3.     var go = Tools.GameObjectHardFind(rawImageGameObjectName);
    4.  
    5.     if (go == null) return; // Can't find. Should probably also log a warning.
    6.  
    7.     go.SetActive(true);
    8.     var r = go.GetComponent<Renderer>();
    9.     var movie = r.material.mainTexture as MovieTexture;
    10.     StartCoroutine(PlayMovie(movie));
    11. }
    12.  
    13. IEnumerator PlayMovie(MovieTexture movie) {
    14.     // Pause the player, play the movie until it's done, then unpause:
    15.     PausePlayer();
    16.     movie.Play();
    17.     while (movie.isPlaying) {
    18.         yield return null;
    19.     }
    20.     UnpausePlayer();
    21. }
    22.  
    23. void PausePlayer() {
    24.     // Pause the player however you need to in your game.
    25.     // Below is a hack for RFPS that makes the player think it's
    26.     // in a conversation, which pauses the player:
    27.     var player = FindObjectOfType<FPSPlayer>();
    28.     player.SendMessage("OnConversationStart", player.transform);
    29. }
    30.  
    31. void UnpausePlayer() {
    32.     var player = FindObjectOfType<FPSPlayer>();
    33.     player.SendMessage("OnConversationEnd", player.transform);
    34. }
    If you're doing in-game cutscenes instead -- for example using Cinema Director or uSequencer -- you can just play them instead of setting up movie textures.
     
    hopeful likes this.
  25. Ludo97

    Ludo97

    Joined:
    Dec 9, 2015
    Posts:
    121
    Ha great, his work, thank you
     
  26. TonyLi

    TonyLi

    Joined:
    Apr 10, 2012
    Posts:
    12,694
    Happy to help!
     
  27. barjed

    barjed

    Joined:
    May 9, 2013
    Posts:
    70
    Hey Tony,

    while extending your wonderful Dialogue System I have found the following problem.

    I have added a SequencerCommand called HeadLookAt, which basically is supposed to use Mecanim's IK http://docs.unity3d.com/ScriptReference/Animator.SetLookAtPosition.html. The issue here is that the transform needs to be fed to the animator in the OnAnimatorIK() event, it doesn't work in Update(), which means I cannot use the default Update method for SeqCommands. Do you perhaps have any idea on how to resolve this issue?

    Thanks!
     
  28. TonyLi

    TonyLi

    Joined:
    Apr 10, 2012
    Posts:
    12,694
    Hi @barjed - SequencerCommand is a MonoBehaviour, so you can implement all the standard methods, including OnAnimatorIK(). However, since sequencer commands are added to the Dialogue Manager, it may be less confusing to make your sequencer command call a secondary script on the subject instead.

    Here's an example:
    Code (csharp):
    1. public class HeadController : MonoBehaviour { // Add to the subject.
    2.  
    3.     public Transform lookTarget = null;
    4.  
    5.     void OnAnimatorIK() {
    6.         if (lookTarget != null) GetComponent<Animator>().SetLookAtPosition(lookTarget.position);
    7.     }
    8. }
    Code (csharp):
    1. public class SequencerCommandHeadLookAt : SequencerCommand {
    2.  
    3.     private HeadController headController;
    4.  
    5.     void Start() {
    6.         var subject = GetSubject(0);
    7.         var lookTarget = GetSubject(1);
    8.         headController = subject.GetComponent<HeadController>();
    9.         headController.lookTarget = lookTarget;
    10.     }
    11.  
    12.     void OnDestroy() {
    13.         headController.lookTarget = null;
    14.     }
    15. }
     
  29. barjed

    barjed

    Joined:
    May 9, 2013
    Posts:
    70
    Great, thanks!
     
  30. NioFox

    NioFox

    Joined:
    Dec 28, 2012
    Posts:
    65
    Hi Tony,
    I'm running into a little conflict using Time.timescale with the Unity UI prefabs.
    For example, when I open the "Generic Unity UI Quest Log Window" with timescale set to 0 beforehand, it will alter the timescale briefly while animating the open sequence. Closing it sets timescale to 1 when it should still be 0. (I have "Pause While Open" unchecked)

    The problem is I am controlling the timescale myself with other scripts. Is there any quick way to make everything work on unscaled time, or would I have to extend everything? I have already manually altered all of the animators, but some things appear to be scripted, like the UnityUITypewriterEffect.

    Edit: After spending some time looking into the scripts, I found the show-stopping problems occurred in UIShowHideController. I was able to quickly modify it, adding
    Code (CSharp):
    1. public bool useUnscaledTime = true;
    to bypass timescale changes and automatically set animators to UnscaledTime update mode. Would it be possible to have something like this added to the next build?
     
    Last edited: Feb 12, 2016
  31. TonyLi

    TonyLi

    Joined:
    Apr 10, 2012
    Posts:
    12,694
    Hi @NioFox - As a temporary fix, comment out line 38 in Dialogue System/Scripts/Supplemental/UI/Tools/UIShowHideController.cs:
    Code (csharp):
    1. Time.timeScale = 1; // Can't guarantee animator is set to Unscaled, so unpause to play.
    I added this as a safeguard for people new to Unity UI who hadn't yet learned about setting the animator's update mode. In the next release, it will just check the animator's update mode and current time scale and log a warning if there's an issue.
     
    NioFox likes this.
  32. NioFox

    NioFox

    Joined:
    Dec 28, 2012
    Posts:
    65
    @TonyLi There is one more small problem I noticed after making the changes: The Quest Log does not populate it's list when timeScale is 0. It will update if I click the buttons, but will be empty when first opened.
     
  33. TonyLi

    TonyLi

    Joined:
    Apr 10, 2012
    Posts:
    12,694
    I'll look into this and get back to you as soon as I can later today.
     
    NioFox likes this.
  34. flashframe

    flashframe

    Joined:
    Feb 10, 2015
    Posts:
    797
    Hi Tony,

    I've been using the Dialogue System Trigger for testing purposes, and I can't seem to change the "reference database" in the inspector. Well, I can change it, but it doesn't appear to repopulate the Conversation Picker dropdown list. The list displays the conversations from the originally reference database. Am I doing it wrong?

    Thanks!

    EDIT: The Dialogue System Controller had lost its reference to the database and reconnecting that has solved it.
     
    Last edited: Feb 12, 2016
  35. TonyLi

    TonyLi

    Joined:
    Apr 10, 2012
    Posts:
    12,694
    Hi @NioFox - The fix for this issue is in the latest patch. (Check your PMs.)

    Hi @flashframe - Glad you got it working!


    Dialogue System for Unity 1.5.9 Patch 2016-02-12 Available

    A patch is available on the Pixel Crushers customer download site. If you'd like access, please PM me your Asset Store invoice number. This patch contains:
    • [2016-02-12] Unity UI scripts no longer force Time.timeScale=1 during show/hide animations. Quest log window properly populates when paused.
    • [2016-02-12] Added Unity UI Ignore Pause Codes component; updated prefabs to use this for reminder lines and use Unscaled Time animation.
    • [2016-02-08] Increased Dialogue Editor node canvas size 10x in each direction.
    • [2016-02-08] Unity UI Typewriter Effect now only allows one copy on a GameObject.
    • [2016-02-08] Added LocalizeUIText.UpdateFieldName().
    • [2016-02-08] Localized Text Table editor can now specify encoding type (UTF8 or Unicode) to use when importing/exporting.
    • [2016-02-08] Dialogue Manager banner image now shows even if the Dialogue System folder moved in the project.
     
    NioFox and Ramsdal like this.
  36. Ludo97

    Ludo97

    Joined:
    Dec 9, 2015
    Posts:
    121
    Hello someone is how to translate this C # code in JS ? thank you

    FindObjectOfType<LevelManager>().LoadGame(PlayerPrefs.GetString("SavedGame"));
     
  37. TonyLi

    TonyLi

    Joined:
    Apr 10, 2012
    Posts:
    12,694
    Hi @Ludo97 -
    Code (csharp):
    1. #pragma strict
    2.  
    3. import PixelCrushers.DialogueSystem;
    4.  
    5. var levelManager : LevelManager = FindObjectOfType(LevelManager);
    6. if (levelManager) {
    7.     levelManager.LoadLevel(PlayerPrefs.GetString("SavedGame"));
    8. }
     
  38. Ludo97

    Ludo97

    Joined:
    Dec 9, 2015
    Posts:
    121
    Thank you , here's my script menu scene that I did but when I press "continue" it does not load my last backup to my other scene

    #pragmastrict

    import PixelCrushers.DialogueSystem;

    var panelInfoCanvas : Canvas;
    var infoOpen = false;
    var levelManager : LevelManager = FindObjectOfType(LevelManager);

    function Start ()
    {

    }

    function Update ()
    {

    }

    function StartGame ()
    {
    Application.LoadLevel("level");
    }

    function ExitGame ()
    {
    Application.Quit();
    }

    function InfoPanel ()
    {
    if (infoOpen == false)
    {
    infoOpen = true;
    panelInfoCanvas.enabled = true;
    }

    elseif (infoOpen == true)
    {
    infoOpen = false;
    panelInfoCanvas.enabled = false;
    }
    }

    function OpenWebsite ()
    {
    Application.OpenURL("https://www.google.com/webhp?ie=utf-8&oe=utf-8");
    }

    function Continue ()
    {
    if (levelManager) {
    levelManager.LoadLevel(PlayerPrefs.GetString("SavedGame"));
    }
    }
     
  39. TonyLi

    TonyLi

    Joined:
    Apr 10, 2012
    Posts:
    12,694
    Hi @Ludo97 - Try this:
    Code (csharp):
    1. #pragma strict
    2.  
    3. import PixelCrushers.DialogueSystem;
    4.  
    5. var panelInfoCanvas : Canvas;
    6. var infoOpen = false;
    7. var levelManager : LevelManager;
    8.  
    9. function Start ()
    10. {
    11.     if (!levelManager)
    12.     {
    13.         // If leveManager wasn't assigned in the inspector, search the scene:
    14.         levelManager = FindObjectOfType(LevelManager);
    15.     }
    16. }
    17.  
    18. function StartGame ()
    19. {
    20.     Application.LoadLevel("level");
    21. }
    22.  
    23. function ExitGame ()
    24. {
    25.     Application.Quit();
    26. }
    27.  
    28. function InfoPanel ()
    29. {
    30.     if (infoOpen == false)
    31.     {
    32.         infoOpen = true;
    33.         panelInfoCanvas.enabled = true;
    34.     }
    35.  
    36.     else if (infoOpen == true)
    37.     {
    38.         infoOpen = false;
    39.         panelInfoCanvas.enabled = false;
    40.     }
    41. }
    42.  
    43. function OpenWebsite ()
    44. {
    45.     Application.OpenURL("https://www.google.com/webhp?ie=utf-8&oe=utf-8");
    46. }
    47.  
    48. function Continue ()
    49. {
    50.     if (levelManager)
    51.     {
    52.         // We found a Level Manager, so load the level named in the SavedGame key:
    53.         var savedGameLevel = PlayerPrefs.GetString("SavedGame");
    54.         Debug.Log("About to load saved level: " + savedGameLevel);
    55.         levelManager.LoadLevel(savedGameLevel);
    56.     } else
    57.     {
    58.         // If we didn't find a Level Manager, log an error:
    59.         Debug.LogError("Can't find Level Manager");
    60.     }
    61. }
    It does two things:
    1. In Start, it looks for the Level Manager if you haven't already assigned it in the inspector.
    2. In Continue, it makes sure we have a Level Manager. Otherwise it logs an error.
    If this doesn't work, check the Console view for any errors.
     
  40. TonyLi

    TonyLi

    Joined:
    Apr 10, 2012
    Posts:
    12,694
    RPG Kit Quest Tutorial

    Unitycoding's RPG Kit is a popular framework to use with the Dialogue System. A few users have asked for a quest tutorial. The first version of the tutorial (text and screenshots, not video) is here:

     
  41. Ludo97

    Ludo97

    Joined:
    Dec 9, 2015
    Posts:
    121
    Thank you for the code.
    When I start the game and I click on the button " continue" its not working , even in build. Here is the error on the photo of the console and two other pictures of different configurations.
     

    Attached Files:

  42. TonyLi

    TonyLi

    Joined:
    Apr 10, 2012
    Posts:
    12,694
    Hi @Ludo97 - The error means the PlayerPrefs key 'SavedGame' is empty.

    Here's an example: JavascriptMainMenuExample.unitypackage

    To play it, add the scenes MenuScene and GameplayScene to your build settings. The Escape key also toggles the InfoPanel.

    For a complete menu solution, I recommend the Dialogue System Menu Template Prefab which you can download from the Dialogue System Extras page.

    The script is:

    Code (csharp):
    1. #pragma strict
    2.  
    3. import PixelCrushers.DialogueSystem;
    4. #if (UNITY_5_0 || UNITY_5_1 || UNITY_5_2)
    5. #else
    6. import UnityEngine.SceneManagement;
    7. #endif
    8.  
    9. var panelInfoCanvas : Canvas;
    10. var infoOpen = false;
    11. var levelManager : LevelManager;
    12.  
    13. function Start ()
    14. {
    15.     if (!levelManager)
    16.     {
    17.         // If leveManager wasn't assigned in the inspector, search the scene:
    18.         levelManager = FindObjectOfType(LevelManager);
    19.         if (!levelManager) Debug.LogError("Can't find Level Manager!");
    20.     }
    21. }
    22.  
    23. function Update ()
    24. {
    25.     if (Input.GetKeyDown(KeyCode.Escape))
    26.     {
    27.         InfoPanel();
    28.     }
    29. }
    30.  
    31. function StartGame ()
    32. {
    33.     Application.LoadLevel(levelManager.defaultStartingLevel);
    34.     InfoPanel();
    35. }
    36.  
    37. function ExitGame ()
    38. {
    39.     Application.Quit();
    40. }
    41.  
    42. function InfoPanel ()
    43. {
    44.     if (infoOpen == false)
    45.     {
    46.         infoOpen = true;
    47.         panelInfoCanvas.enabled = true;
    48.     }
    49.  
    50.     else if (infoOpen == true)
    51.     {
    52.         infoOpen = false;
    53.         panelInfoCanvas.enabled = false;
    54.     }
    55. }
    56.  
    57. function OpenWebsite ()
    58. {
    59.     Application.OpenURL("https://www.google.com/webhp?ie=utf-8&oe=utf-8");
    60. }
    61.  
    62. function Continue ()
    63. {
    64.     var savedGameLevel = PlayerPrefs.GetString("SavedGame");
    65.     if (savedGameLevel == "")
    66.     {
    67.         // No saved game:
    68.         Debug.LogError("PlayerPrefs key 'SavedGame' is empty");
    69.     }
    70.     else
    71.     {
    72.         // The SavedGame key is good, so load the level:
    73.         Debug.Log("About to load saved level: '" + savedGameLevel + "'");
    74.         levelManager.LoadLevel(savedGameLevel);
    75.         InfoPanel();
    76.     }
    77. }
    78.  
    79. function SaveGame ()
    80. {
    81.     InfoPanel();
    82.     #if UNITY_5_0 || UNITY_5_1 || UNITY_5_2
    83.         var currentScene = Application.loadedLevelName; // Unity 5.0-5.2
    84.     #else
    85.         var currentScene = SceneManager.GetActiveScene().name; // Unity 5.3+
    86.     #endif
    87.     DialogueManager.ShowAlert("Saving game...");
    88.     PlayerPrefs.SetString("SavedGame", currentScene);
    89. }
     
    Last edited: Feb 15, 2016
  43. TonyLi

    TonyLi

    Joined:
    Apr 10, 2012
    Posts:
    12,694
    Love/Hate 50% Off Today - 24 Hour Sale

    Happy Valentine's Day, everyone! Love/Hate, which makes a good companion to the Dialogue System, is today's 24 Hour Sale!
     
  44. Ludo97

    Ludo97

    Joined:
    Dec 9, 2015
    Posts:
    121
    I wrote the script and here's what he said:
     

    Attached Files:

  45. TonyLi

    TonyLi

    Joined:
    Apr 10, 2012
    Posts:
    12,694
    Sorry, I forgot one line at the top:
    Code (csharp):
    1. import UnityEngine.SceneManagement;
     
  46. Ludo97

    Ludo97

    Joined:
    Dec 9, 2015
    Posts:
    121
    There are more error but when I save in my scene "level" and I return to my scene "menu" I put "continue" and nothing happens , is the message :
     

    Attached Files:

  47. TonyLi

    TonyLi

    Joined:
    Apr 10, 2012
    Posts:
    12,694
    Hi @Ludo97 - It says that it's loading the scene 'menu'. Are you saving in the scene 'menu'? Can you compare the example I sent you to your own script? Please also feel free to send an example project to tony (at) pixelcrushers.com. I'll be happy to take a look.
     
  48. Ludo97

    Ludo97

    Joined:
    Dec 9, 2015
    Posts:
    121
    Ha it's good, I 'm an idiot , I did not put the right name but finally if there had a small mistake , thank you patience
     
  49. TonyLi

    TonyLi

    Joined:
    Apr 10, 2012
    Posts:
    12,694
    No worries, glad it's working now! :)
     
  50. TonyLi

    TonyLi

    Joined:
    Apr 10, 2012
    Posts:
    12,694
    Requesting user feedback: Zooming

    I'm adding the ability to zoom in and out of the Dialogue Editor's conversation node canvas, and I'd like to get your feedback.

    Would you prefer to zoom with the mouse scroll wheel? If so, what equivalent method do one-button mouse users prefer?

    Or would you rather adjust the zoom factor with an onscreen slider?