Search Unity

  1. Unity 6 Preview is now available. To find out what's new, have a look at our Unity 6 Preview blog post.
    Dismiss Notice
  2. Unity is excited to announce that we will be collaborating with TheXPlace for a summer game jam from June 13 - June 19. Learn more.
    Dismiss Notice
  3. Dismiss Notice

[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,758
    Articy X Support Added

    The Dialogue System Extras page has a patch that adds Articy X support to the articy:draft importer. This addition will also be in version 2.2.43. Support for articy's voiceover addon is still in progress.

    upload_2024-2-13_20-19-32.jpeg
     
  2. howa9495

    howa9495

    Joined:
    Oct 9, 2022
    Posts:
    8
    I am using Dialogue system events and my events will be reset after any playback. How should I solve this problem?
    I also use the survival engine in my project, and the unity version is 2022.3.14f1.
     
  3. TonyLi

    TonyLi

    Joined:
    Apr 10, 2012
    Posts:
    12,758
    Hi!

    Make sure you have assigned the Player instance in the scene to the Dialogue System Events elements:

    upload_2024-2-14_21-11-41.png

    Or, better yet, edit the prefab (not the scene instance) and set up the Dialogue System Events component on the prefab.
     
  4. howa9495

    howa9495

    Joined:
    Oct 9, 2022
    Posts:
    8
    Thanks for your suggestion, unfortunately this method doesn't solve it.
     
  5. TonyLi

    TonyLi

    Joined:
    Apr 10, 2012
    Posts:
    12,758
    Check for any errors or warnings in the Console window. Try to get the Console to be clean while in play mode by resolving any errors or warnings that appear. You might be missing an important error or warning message.

    If that doesn't help, close Unity, delete the Library folder, and reopen Unity. Unity will take some time to rebuild the Library folder. Then try assigning the events to the Player prefab again if they're not currently assigned.

    To help isolate the problem, please play the Dialogue System's DemoScene1. After playing, check the Dialogue System Events on DemoScene1's Player GameObject. Are the events still assigned to it? If so, then there may be an issue in your scene. If the events are also missing in DemoScene1, check if you have any custom editor extensions that may be causing the problem. (If so, this extension may be logging an error or warning in the Console window.)

    If that doesn't help, please send a reproduction project to tony (at) pixelcrushers.com.
     
  6. howa9495

    howa9495

    Joined:
    Oct 9, 2022
    Posts:
    8
    Thanks for your help, it works normally after I deleted the library folder.
     
  7. TonyLi

    TonyLi

    Joined:
    Apr 10, 2012
    Posts:
    12,758
    Glad to help!
     
  8. TonyLi

    TonyLi

    Joined:
    Apr 10, 2012
    Posts:
    12,758
    Version 2.2.43 Released

    Version 2.2.43 is now available on the Asset Store!

    Highlights: Articy X import, Emerald AI 2024 Support

    Release Notes:

    Core:
    • Improved: Added DialogueManager.HideAllAlerts().
    • Improved: Added utility method DialogueManager.GetConversationTitle(id).
    • Improved: Moved actor name prepending to StandardUISubtitlePanel for compatibility with ConversationControl.SkipAll() when subtitle panel's Add Actor Name is ticked.
    • Improved: AudioWait[Once]() now accounts for time scaled and pitch altered audio clip durations.
    • Improved: Added CharacterInfo.GetField(), GetField[type]() utility methods.
    • Improved: Added ConversationControl > Don't Skip All On Last Conversation Line.
    • Improved: Exposed PersistentDataManager.AppendSimStatus(StringBuilder, and ExpandCompressedSimStatusData().
    • Improved: Text Table Editor now has gear menu > Import > From Localize UI menu feature.
    • Improved: Added editor event hook DialogueEditorWindow.customDrawConversationInspector.
    • Fixed: Subtitle panel Visibility options 'Until Superceded Or Actor Change' and 'Until Superceded Or Actor Change Or Response Menu' were not being superceded.
    • Fixed: OverrideDialogueUI now correctly observes Don't Destroy Prefab Instance.
    • Fixed: Bug in SMSDialogueUI returning to conversation when first entry is assigned to player menu and no menu choices were made when conversation was exited.
    • Fixed: Possible NullReferenceException in ConversationView.NotifyParticipantsOnConversationLineEnd.
    • Fixed: BarkController now exclude rich text and control codes from {{end}} value.
    • Fixed: SetLocalizedFonts now listens for UILocalizationManager.languageChanged events.
    • Fixed: Implemented workaround for TMPro bug incorrectly updating mesh when changing languages and font in LocalizeUI component.
    • Renamed "Alocai" to "Altagram" in Localization Export/Import dropdown.
    • Timeline: Removed "variable 'audioClip' is declared but never used" warning in PreviewUI.cs.
    Third Party Support:
    • Adventure Creator: Can pass parameter narrator to ACSpeech() to speak through narrator.
    • Arcweave: Added options to import extra dialogue entry fields, "Portrait #" fields for extra portraits.
    • articy:draft: Added support for Articy X (voiceover addon support still in progress); ArticyConverter class's methods are now virtual and overridable; Added "Include Feature Name" checkbox to prepend feature name to properties that are imported as custom fields.
    • Emerald AI 2024: Added integration for new Emerald AI 2024 version.
    • i2 Localization: Updated for API changes in i2 Localization 2.8.22f4.
    • Ink: Added BarkInkOnIdle component; can now use => in {Sequence(...)} commands instead of -> which Ink doesn't allow; fixed InkEntrypoint.FromString() parsing bug.
    • Invector character controllers: Updated for 2.6.4.
    • RPG Builder: Now hides alerts (if visible) when returning to main menu.
    • Twine: Fixed import issue when database has more than one player actor involved in a conversation.
     
  9. m4a44

    m4a44

    Joined:
    Mar 13, 2013
    Posts:
    45
    Hey, is there any chance that adding an object reference field to a dialogue node would be possible (worth my time) and something that I could add on my end?

    Basically, we want to be able to hard reference files in the Project (for use when a line is used), and also add a field for easy access to the inspector window (along side the Dialogue Text, Script, Conditions, etc.). Intention is to make it more idiot proofed than string path references, and probably use it in future projects...
     
  10. TonyLi

    TonyLi

    Joined:
    Apr 10, 2012
    Posts:
    12,758
    Hi! No need to write any code. The Dialogue System Extras page has a package (direct download) that adds an "Asset" field type using the Dialogue System's custom field type capability. You can use it as-is or customize it without having to touch any actual Dialogue System scripts.
     
  11. m4a44

    m4a44

    Joined:
    Mar 13, 2013
    Posts:
    45
    Ok, that's great to hear.

    However, when testing it out, the field wasn't being kept between re-opening Unity (and sometimes between switching conversations).
    After closing and opening the project, the DialogueAssetCatalog in the Resources folder had no elements (as in, it doesn't look like Unity was saving it after changes).

    Adding an EditorUtility.SetDirty in the Add/Remove (in a preprocessor) fixed it for me.
     
  12. TonyLi

    TonyLi

    Joined:
    Apr 10, 2012
    Posts:
    12,758
    Ah, looks like I hadn't updated the download on the Extras page. I just updated it (with the same fix you added on your own, I'm sure). The included Example sub-package is also updated, too.
     
    m4a44 likes this.
  13. GrassWhooper

    GrassWhooper

    Joined:
    Mar 25, 2016
    Posts:
    114
    Maybe a bug, maybe my setup, but so i started using barking recently and this is my trigger.

    Lets say, the player ignores the trigger and just walks forward, so this trigger is never called.


    upload_2024-3-3_14-34-27.png

    I have my own saving system that calls.

    Code (CSharp):
    1.             if (DialogueManager.instance)
    2.                 return PersistentDataManager.GetSaveData();

    Now, once this function is called, i get an error on the game object on the picture that is a null error.

    Code (CSharp):
    1. NullReferenceException: Object reference not set to an instance of an object
    2. PixelCrushers.DialogueSystem.DialogueSystemTrigger.OnRecordPersistentData () (at Assets/Plugins/Pixel Crushers/Dialogue System/Scripts/Triggers/Triggers/DialogueSystemTrigger.cs:1191)
    3. UnityEngine.GameObject:SendMessage(String, SendMessageOptions)
    4. PixelCrushers.DialogueSystem.PersistentDataManager:SendPersistentDataMessage(String) (at Assets/Plugins/Pixel Crushers/Dialogue System/Scripts/Save System/PersistentDataManager.cs:214)
    5. PixelCrushers.DialogueSystem.PersistentDataManager:Record() (at Assets/Plugins/Pixel Crushers/Dialogue System/Scripts/Save System/PersistentDataManager.cs:185)
    6. PixelCrushers.DialogueSystem.PersistentDataManager:GetSaveData() (at Assets/Plugins/Pixel Crushers/Dialogue System/Scripts/Save System/PersistentDataManager.cs:397)
    7. JG_Lib.Saving.S_DialogueSystem:CaptureState() (at Assets/01_JG_Lib/IntegrationsCore/DialogueSystem/Interactables/Saver/S_DialogueSystem.cs:19)
    Upon investigating it appears that the variable named "barkHistory" in this function is in fact null in this scenario (where the player decided to NOT, interact with this trigger).

    Code (CSharp):
    1.         public void OnRecordPersistentData()
    2.         {
    3.             if (enabled && !string.IsNullOrEmpty(barkConversation))
    4.             {
    5.                 DialogueLua.SetActorField(GetBarkerName(), "Bark_Index", barkHistory.index);
    6.             }
    7.         }

    Thought i'd report this, naturally if i delete the dialogue trigger, or there is no conversation in the bark, then everything works fine.
     

    Attached Files:

    Last edited: Mar 3, 2024
  14. TonyLi

    TonyLi

    Joined:
    Apr 10, 2012
    Posts:
    12,758
    Hi - There's a patch for that (see attached). The fix will also be in version 2.2.44.
     

    Attached Files:

    GrassWhooper likes this.
  15. halley

    halley

    Joined:
    Aug 26, 2013
    Posts:
    2,556
    Probably someone's done this, but it might be nice as a built-in or community-added example:

    Code (CSharp):
    1. // CustomLuaFunctions.cs
    2. //
    3. using System;
    4. using System.Reflection;
    5. using System.Collections.Generic;
    6. using UnityEngine;
    7.  
    8. using PixelCrushers.DialogueSystem;
    9.  
    10. namespace Whatever
    11. {
    12.     [AttributeUsage(AttributeTargets.Method)]
    13.     public class LuaFunctionAttribute: Attribute { }
    14.  
    15.     //
    16.     // Builds on examples from Dialogue System documentation:
    17.     // https://pixelcrushers.com/dialogue_system/manual/html/lua_in_scripts.html
    18.     //
    19.     // Extend this class, implement methods which use a [LuaFunction] attribute,
    20.     // and drop the behaviour onto any active object, such as the Dialogue Manager.
    21.     // Each LuaFunction-tagged method will be registered for use in Lua scripts,
    22.     // including when interpolated in dialogue strings.  For example,
    23.     //
    24.     //    [LuaFunction] string ChestContents() { return "nothing"; }
    25.     //
    26.     //    "The chest contains [lua(ChestContents())]."
    27.     //
    28.     public class CustomLuaFunctions: MonoBehaviour
    29.     {
    30.         private List<string> names;
    31.  
    32.         public virtual void OnEnable()
    33.         {
    34.             System.Type type = GetType();
    35.  
    36.             if (names == null)
    37.             {
    38.                 names = new List<string>();
    39.                 foreach (MethodInfo method in type.GetMethods())
    40.                     foreach (Attribute attrib in method.GetCustomAttributes())
    41.                         if (attrib.GetType() == typeof(LuaFunctionAttribute))
    42.                             if (LegalLuaFunction(method))
    43.                                 names.Add(method.Name);
    44.             }
    45.  
    46.             foreach (string name in names)
    47.             {
    48.                 Debug.Log($"Registering custom Lua function {name}");
    49.                 Lua.RegisterFunction(name, this, type.GetMethod(name));
    50.             }
    51.         }
    52.  
    53.         private bool LegalLuaFunction(MethodInfo method)
    54.         {
    55.             //REVIEW: could check the MethodInfo to see if it conforms.
    56.             // Lua only supports types:  bool, double, string.
    57.             return true;
    58.         }
    59.  
    60.         public virtual void OnDisable()
    61.         {
    62.             foreach (string name in names)
    63.                 Lua.UnregisterFunction(name);
    64.         }
    65.     }
    66. }
     
    TonyLi and kdgalla like this.
  16. TonyLi

    TonyLi

    Joined:
    Apr 10, 2012
    Posts:
    12,758
    Thanks! That's a really good idea. One note: Careful if you put this on a GameObject such as the Dialogue Manager that survives scene changes (i.e., persistent singleton). If you change to another scene that has another Dialogue Manager that the persistent singleton will destroy, the destroyed Dialogue Manager will run its OnDisables, which will unregister the function.
     
  17. carmofin

    carmofin

    Joined:
    May 13, 2017
    Posts:
    116
    Sorry for the late reply, I only got the motivation to dig into this problem deeper now.
    I was having issues with the fade in fade out effect from the scene transition function. The fade out works fine, but the fade in just doesnt work.
    I am attaching a videofile showing the issue. I think it is related to the animator, as it doesnt behave the way it should, but even after playing around for a while i cant find the right settings...
     
  18. TonyLi

    TonyLi

    Joined:
    Apr 10, 2012
    Posts:
    12,758
    Hi! How are you changing scenes? As a test, if you add the Dialogue System's DemoScene1 and DemoScene2 to build settings, does the fade work correctly if you move between DemoScene1 and DemoScene2?
     
  19. carmofin

    carmofin

    Joined:
    May 13, 2017
    Posts:
    116
    It works fine in the demo scenes.
     
  20. TonyLi

    TonyLi

    Joined:
    Apr 10, 2012
    Posts:
    12,758
    How are you changing scenes in your own scenes? Are you using any of these techniques?
     
  21. carmofin

    carmofin

    Joined:
    May 13, 2017
    Posts:
    116
  22. carmofin

    carmofin

    Joined:
    May 13, 2017
    Posts:
    116
    What I need is an explanation for why, when the fade in animation is supposed to be played, it goes to the end of the animation instantly. If I set the animation speed to something like 0.1 I can see it plays the very end of the animation.
     
  23. TonyLi

    TonyLi

    Joined:
    Apr 10, 2012
    Posts:
    12,758
    Thanks for the screenshot. That's a good way to change scenes. Check the Animator on your SceneFaderCanvas. If it uses the exact same animator controller, compare the settings on the Standard Scene Transitions Managers. If it's a different animator controller, compare the configurations of the transition arrows. Or, if you prefer, feel free to send me a reproduction project with reproduction steps. I'll be happy to take a look directly in the morning.
     
  24. carmofin

    carmofin

    Joined:
    May 13, 2017
    Posts:
    116
    It uses the same animator.
    Did my video leave out anything that could be responsible for this problem? Please, development has been stuck for half a year now because I can't find whats causing this...
    How do I just casually send you a 40 gig project...
     
  25. TonyLi

    TonyLi

    Joined:
    Apr 10, 2012
    Posts:
    12,758
    If you do want to send a repro project, you can use Mega, WeTransfer, MS OneDrive, Dropbox, etc. (Avoid Google Drive if possible; for some reason it has the most timeouts when trying to download large files.) You only need to zip up the Assets, Packages, and ProjectSettings folder. Exclude everything else.

    I couldn't read some of the Animator values at 720p. They were very blurry.

    If you can, back up your project and update to the current Dialogue System version if you're not already on it. This will ensure that we're looking at the same versions.

    As a test (or possibly a final solution), please:

    1. Remove these components from your Dialogue Manager: SaveSystem, JsonDataSerializer, PlayerPrefsSavedGameDataStorer, StandardSceneTransitionManager. Your DataSerializer or SavedGameDataStorer components may be different (e.g., DiskSavedGameDataStorer).
    2. Download the SaveSystemPrefabs (direct download) from the Dialogue System Extras page and import it. It will import into Plugins / Pixel Crushers / Common / Save System Prefabs.
    3. Add the LoadingScreen scene to your build settings.
    4. Add the Save System prefab to your scene.
    5. Test.
    If this works, you can continue with this setup. If you don't want to use a loading screen, remove the LoadingScreen scene from your build settings, and on the Save System instance clear the Standard Scene Transition Manager's Load Scene Name field.
     
  26. carmofin

    carmofin

    Joined:
    May 13, 2017
    Posts:
    116
    I am using a starter scene that is loaded and kept in dontdestroy. before I used that approach everything was working fine. I updated today. I want to FIX this if possible, not give up and see if maybe some extra feature doesnt run into the same issue. What is causing the animation to be skipped? Why does it seem to work when theres not much to be loaded? It feels like ther eshould be an obvious and common answer...
     
  27. carmofin

    carmofin

    Joined:
    May 13, 2017
    Posts:
    116
    Here, I slowed down the animation and you can clearly see whats going on:
    Every time I go into a different scene, half the animation is simply skipped.
    At normal speed, it just skips the entire thing.
     
  28. TonyLi

    TonyLi

    Joined:
    Apr 10, 2012
    Posts:
    12,758
    That's why I wanted you to check the Save System prefab. It's not a new feature. It's the same set of components except preconfigured to work correctly. If it works, we can take a look at what the differences are. If it works and DemoScene1 works, then those are two working models to look at for any differences in your setup. (I've finished work for the night but I'll check back first thing in the morning.)
     
    Last edited: Mar 5, 2024
  29. carmofin

    carmofin

    Joined:
    May 13, 2017
    Posts:
    116
    I did as instructed and the issue persists.
     
  30. carmofin

    carmofin

    Joined:
    May 13, 2017
    Posts:
    116
    Upon looking at whats going on, the fade in is playing in the loading screen? I usualy dont have a loading screen, so maybe thats why it just skips the animation?
    So how do I prevent the fade in to be played on the loading scene?
     
  31. TonyLi

    TonyLi

    Joined:
    Apr 10, 2012
    Posts:
    12,758
    Thanks for running those tests, by the way. They provide important additional information that helps narrow down the issue. The info narrows down the issue to your scene since DemoScene1 works and the SaveSystemPrefabs are working in many dozens of customer projects, so this helps us look at the correct place.

    I'm not sure of the current setup of your Standard Scene Transition Manager (in case you've changed some settings), but if the Loading Scene Name field is blank, it will not use a loading screen scene. In this case, the order of operations will be:
    • Sets the Standard Scene Transition Manager's Leave Scene Transition > Trigger and waits for the maximum of Animation Duration and Min Transition Duration (which in your video is 1 second).
    • Loads the scene using SceneManager.LoadSceneAsync() or, if the scene isn't in build settings but you've enabled Addressables, using Addressables.LoadSceneAsync(). Waits for the scene to load -- that is, for the async operation to return IsDone == true.
    • Sets the Standard Scene Transition Manager's Enter Scene Transition > Trigger and waits for the maximum of Animation Duration and Min Transition Duration.
    Some things to try to get more info:
    • Make sure the SceneFaderCanvas's Update Mode is set to Unscaled Time.
    • As a test, tick the Standard Scene Transition Manager's Pause During Transition checkbox. This will provide an additional data point.
    • Are there any errors or warnings in the Console window?
     
  32. carmofin

    carmofin

    Joined:
    May 13, 2017
    Posts:
    116

    Here's a view of the current setup.
     
  33. carmofin

    carmofin

    Joined:
    May 13, 2017
    Posts:
    116
    Additionally, as you know, it is now running on your default setup. I have made zero adjustments. Still, it is working fine on the demos, but acting like this on my own scenes.
    I really want to focus on why the scene transition animation plays on the loading scene, instead of the scene we are going into. (and there are no errors related to the dialogue plugin)
     
  34. TonyLi

    TonyLi

    Joined:
    Apr 10, 2012
    Posts:
    12,758
    Hi! I see two things in the animator controller that you're using. First, there's a new transition arrow between FadeToBlack and FadeFromBlack:

    upload_2024-3-5_11-17-2.png

    And this might be causing the second issue. The FadeFromBlack state is starting while the FadeToBlack is still playing:

    upload_2024-3-5_11-17-28.png

    The most likely culprit is a Transition Duration (i.e., cross-fade) on the transition arrow:

    upload_2024-3-5_11-18-41.png

    The transition arrow shouldn't be there in the first place. But, as a future note for other animators, if you need one animation to completely finish before playing the next state, set Exit Time to 1 and Transition Duration to 0. However, for this case, please remove that transition arrow.
     
  35. carmofin

    carmofin

    Joined:
    May 13, 2017
    Posts:
    116
    If you look at my video yesterday, the arrow was not there. that got added by installing your package. I have removed it. The problem persists.
     
  36. carmofin

    carmofin

    Joined:
    May 13, 2017
    Posts:
    116

    Here with the removed arrow.
     
  37. TonyLi

    TonyLi

    Joined:
    Apr 10, 2012
    Posts:
    12,758
    Hi - Please import this patch, which I'll include in DS version 2.2.44. When the Animator is set to Unscaled Time and the scene takes a long time to initialize (e.g., length Awake() and OnEnable() methods), it looks at the real time between when the scene finished loading and when the Awake()/OnEnable() methods finish, and it advances the animation state by that amount. Some choices of solutions are:
    1. Use the attached patch. It waits to trigger the animation state until after the Awake()/OnEnable() methods have finished. You can test it by importing the attached example scene package. Try it first without the patch, then with the patch. Add both scenes to build settings, play Scene Change Example Scene 1, and click the button to change scenes. Scene 2 has a lengthy Awake() method.
    2. Or change the animator's Update Mode to Normal. This will account for lengthy scene initialization.
     

    Attached Files:

  38. carmofin

    carmofin

    Joined:
    May 13, 2017
    Posts:
    116
    Hi!
    Yay, thank you so much, we are getting to the bottom of this now!
    I'm attaching another video of what it looks like now, there is one issue left I don't know how to resolve.
    Namels, after the fadeout, the last frame doesnt remain black, but shows everything as it loads (I have taken out the loading screen, but if it is there, its the same problem).
    Then on the next scene, the very first frame should also be black, but instead it shows the scene in its default state, t-pose and everything.
    Any idea how I can adress these?
     
  39. TonyLi

    TonyLi

    Joined:
    Apr 10, 2012
    Posts:
    12,758
    Hi - Remove the transition arrow from "Fade To Black" to "Nothing". The animator must remain in the Fade To Black state until it's time to fade back in from black.
     
  40. TonyLi

    TonyLi

    Joined:
    Apr 10, 2012
    Posts:
    12,758
  41. carmofin

    carmofin

    Joined:
    May 13, 2017
    Posts:
    116
    And with that the issue is fully recoved! Thank you very, very much, this has been a nightmare for me.
    One last question, if I may.
    How is it possible that noone ever had this issue before me? Maybe having a starter scene isn't as common an approach as I thought?
     
  42. TonyLi

    TonyLi

    Joined:
    Apr 10, 2012
    Posts:
    12,758
    Glad to help! It's hard to say -- although plenty of people use starter scenes, maybe no one had added the extra transition arrows, or their Awake methods weren't so lengthy. Anyway, I'm glad it's working now!
     
  43. halley

    halley

    Joined:
    Aug 26, 2013
    Posts:
    2,556
    Hey, TonyLi,

    Trying to make use of Lua Functions in C# again, and a little confused about the boxing and unboxing of Lua.Result values. Here's a short example:

    Code (CSharp):
    1.     public int Encounter(string actor)
    2.     {
    3.         // Perform the increment.
    4.         Lua.Result result = Lua.Run(
    5.             $"Actor[\"{actor}\"].Encounters = " +
    6.             $"Actor[\"{actor}\"].Encounters + 1");
    7.         Debug.Log($"Encounter result: {result.AsFloat}");
    8.         Debug.Log($"Encounter result: {result.AsInt}");
    9.         Debug.Log($"Encounter result: {result.AsString}");
    10.  
    11.         // Try to get the results of the increment.
    12.         result = Lua.Run(
    13.             $"Actor[\"{actor}\"].Encounters");
    14.         Debug.Log($"Encounter with {actor}: {result.AsFloat}");
    15.         Debug.Log($"Encounter with {actor}: {result.AsInt}");
    16.         Debug.Log($"Encounter with {actor}: {result.AsString}");
    17.  
    18.         // Try harder to get the results of the increment.
    19.         result = DialogueLua.GetActorField(actor, "Encounters");
    20.         Debug.Log($"Encounter with {actor}: {result.AsFloat}");
    21.         Debug.Log($"Encounter with {actor}: {result.AsInt}");
    22.         Debug.Log($"Encounter with {actor}: {result.AsString}");
    23.         return result.asInt;
    24. }
    The actual incrementing part works. When trying to make sure it was working though, I had trouble getting the result of the increment. Only the third approach actually returns something other than 0/empty. I'm trying to figure out why.

    Secondly, in my game I can't really use the LuaConsole (too much input interaction between game and keyboard) but would really like to be able to debug the values. The database views don't seem to show live values either. Would be great if you made a modeless EditorWindow version of the LuaConsole. If you help me understand why my above expressions aren't returning from Lua.Run, maybe I can provide a suitable Lua EditorWindow wrapper.
     
  44. TonyLi

    TonyLi

    Joined:
    Apr 10, 2012
    Posts:
    12,758
    Hi @halley -

    You may need to sanitize your actor name:
    Code (csharp):
    1. result = Lua.Run($"Actor[\"{DialogueLua.StringToTableIndex(actor)}\"].Encounters");
    More info: Important Note About Table Indices

    For the Lua Console, try ticking the Pause Game While Open checkbox. This will set Time.timeScale to zero while the Lua Console is open, which may prevent keyboard interference from other scripts that listen for input in Update/FixedUpdate/LateUpdate/etc.
     
  45. halley

    halley

    Joined:
    Aug 26, 2013
    Posts:
    2,556
    Well, as I said, the top entry which does the incrementing, actually works. I just get nothing useful in the Lua.Result. The actor names are simple single-word all-letter ASCII names.
     
  46. TonyLi

    TonyLi

    Joined:
    Apr 10, 2012
    Posts:
    12,758
    Hi! As a general rule, unless you're absolutely certain that all names will be a single-word all-letter name, please use DialogueLua.StringToTableIndex() to sanitize it.

    To fix the second code block, use the return keyword:

    Code (csharp):
    1. result = Lua.Run($"return Actor[\"{DialogueLua.StringToTableIndex(actor)}\"].Encounters");
     
  47. halley

    halley

    Joined:
    Aug 26, 2013
    Posts:
    2,556
    That was the sauce. Thanks, TonyLi!
     
  48. TonyLi

    TonyLi

    Joined:
    Apr 10, 2012
    Posts:
    12,758
    Glad to help!
     
  49. BACALL

    BACALL

    Joined:
    Feb 21, 2017
    Posts:
    90
  50. TonyLi

    TonyLi

    Joined:
    Apr 10, 2012
    Posts:
    12,758
    Hi!
    Are there any errors or warnings in the Console window?

    What version of the Dialogue System for Unity are you using? You can find the version number in the Welcome Window or in the file Plugins / Pixel Crushers / Dialogue System / _README.txt.

    Are you using any editor extensions that might be suppressing menu items?

    Here's a screenshot of the menu item:

    upload_2024-3-11_22-4-28.png

    Ignore the "Addon for OpenAI" submenu unless you've imported the separate Dialogue System Addon for OpenAI asset.