Search Unity

[70% OFF - FLASH DEAL] 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,706
    Hi @VariantPolygon - Here are three ways. The first two are similar, so I'll group them.

    1 & 2. Add a Dialogue System Events component, or a script with an OnQuestStateChange() method, to the Dialogue Manager. If you use Dialogue System Events, add a script with a method that you can hook up to the OnQuestStateChange() UnityEvent. In the method, check the quest state and do something. For example, the script might look like this:

    Code (csharp):
    1. // Uses built-in OnQuestStateChanged() method.
    2.  
    3. using System;
    4. using UnityEngine;
    5. using UnityEngine.Events;
    6. using PixelCrushers.DialogueSystem;
    7.  
    8. [Serializable]
    9. public class QuestEvents
    10. {
    11.     [QuestPopup] public string requiredQuestName;
    12.     public UnityEvent onAccepted;
    13.     public UnityEvent onCompleted;
    14. }
    15.  
    16. public class QuestStateEvents : MonoBehaviour
    17. {
    18.     public QuestEvents[] questEvents;
    19.  
    20.     void OnQuestStateChange(string questName)
    21.     {
    22.         QuestState state = QuestLog.GetQuestState(questName);
    23.         foreach (QuestEvents questEvent in questEvents)
    24.         {
    25.             if (questEvent.requiredQuestName == questName)
    26.             {
    27.                 if (state == QuestState.Active) questEvent.onAccepted.Invoke();
    28.                 else if (state == QuestState.Success) questEvent.onCompleted.Invoke();
    29.             }
    30.         }
    31.     }
    32. }
    (Edit: Make a couple of fixes courtesy of VariantPolygon.)

    3. Or you can assign a replacement method to QuestLog.SetQuestStateOverride. Your replacement can call the default method and then do extra work. Example:

    Code (csharp):
    1. QuestLog.SetQuestStateOverride = CustomSetQuestState;
    2.  
    3. void CustomSetQuestState(string questName, string stateString)
    4. {
    5.     QuestLog.DefaultSetQuestState(questName, stateString);
    6.     QuestState state = QuestLog.StringToState(stateString);
    7.     if (state == QuestState.Active) // do something
    8.     else if (state == QuestState.Success) // do something else
    9. }
     
    Last edited: Mar 17, 2021
    VariantPolygon likes this.
  2. TonyLi

    TonyLi

    Joined:
    Apr 10, 2012
    Posts:
    12,706
    New Asset Store Customer Sale - Dialogue System for $9.99

    If you're new to the Asset Store and considering buying the Dialogue System for Unity, they're running a promotion this month. You can get your first Asset Store purchase for only $9.99, including the Dialogue System (regularly $85 USD) with coupon code MARCHWELCOME.
     
  3. VariantPolygon

    VariantPolygon

    Joined:
    Nov 24, 2012
    Posts:
    6
    Hey Tony, thank you so much, that worked perfectly! I used the QuestStateEvents script which was just missing:
    Code (CSharp):
    1. using UnityEngine.Events;
    Other than that, I just needed to change 'quest' to 'state' in line 27:
    Code (CSharp):
    1. else if (state == QuestState.Success) questEvent.onCompleted.Invoke();
     
    TonyLi likes this.
  4. TonyLi

    TonyLi

    Joined:
    Apr 10, 2012
    Posts:
    12,706
    Glad to help! I just updated the scripts above with those fixes in case someone else refers to it in the future.
     
  5. Stickeyd

    Stickeyd

    Joined:
    Mar 26, 2017
    Posts:
    174
    I have this weird framerate spike when bark appears, any idea what could it be?
     
  6. TonyLi

    TonyLi

    Joined:
    Apr 10, 2012
    Posts:
    12,706
    Hi @Stickeyd - Try assigning the Barker and Target to your bark component / DialogueManager.Bark() call.

    Can you expand the Profiler's Hierarchy a few more levels for ConversationModel.SetParticipants? My suspicion is that it's either looking for the barker or target (if they're not assigned), or you've assigned legacy textures to the actors' Portraits sections and it's doing a one-time runtime conversion to sprites in case the bark UI needs to show the barker's portrait image. If you've assigned a legacy texture, unassign it and assign a sprite (i.e., change the image's import settings). If you can't assign the actors to the bark component, then add Dialogue Actor components if possible. This will allow the Dialogue System for find the correct GameObjects much faster.
     
  7. Sicryn

    Sicryn

    Joined:
    Apr 18, 2018
    Posts:
    9
    Hello Tony,

    I am faced with a silly problem that I do not understand.
    Until now I used [lua (RandomElement (Variable ["Conv_MineurEnter"]))] to say random words from my variable Conv / MineurEnter, but overnight I got this error:
    Dialog System: Lua code 'return RandomElement (Variable ["Conv_MineurEnter"])' threw exception 'Tried to invoke a function call on a non-function value. If you're calling a function, is it registered with Lua? '
    What's weird is that it used to work and I don't think I changed anything impacting it.
    I tried by putting for example [lua (RandomElement ("Hello | Hi"])] to see if it came from my variable but it does the same thing.
    Do you know where it could come from?

    Thanks in advance and thank you for this great tool!
     
  8. TonyLi

    TonyLi

    Joined:
    Apr 10, 2012
    Posts:
    12,706
    Hi @Sicryn - RandomElement() is a C# method that the Dialogue System registers with Lua. The error suggests that something is unregistering it.

    What changed between the time is was working and the time it stopped working?
     
  9. Sicryn

    Sicryn

    Joined:
    Apr 18, 2018
    Posts:
    9
    Well .. I updated the plug-in and think that's all I'm doing that might change something.
    I would try to find out tomorrow if something else, which I don't have in mind and which could have an impact, would have changed. :)
     
  10. TonyLi

    TonyLi

    Joined:
    Apr 10, 2012
    Posts:
    12,706
    Sounds good! Please also feel free to send a reproduction project to tony (at) pixelcrushers.com if you'd like me to take a direct look.
     
  11. Sicryn

    Sicryn

    Joined:
    Apr 18, 2018
    Posts:
    9
    Hi !
    I have trouble understanding, the RandomElement function still exists in the C # code, and if I test it in another project it works but there, no way ... While I did not touch anything that would impact.
    Isn't there a reason why Lua no longer detects a function?
    I forgot to specify it earlier, but I'm using the AC Bridge, but it already was on when it was working so I don't think that it is what impacts?
    Unfortunately it's a bit complicated for me to send the project even using Unity's tool.
     
  12. TonyLi

    TonyLi

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

    Does the problem happen right away, or only after changing scenes during play?
     
  13. Sicryn

    Sicryn

    Joined:
    Apr 18, 2018
    Posts:
    9
    As soon as we talk to the NPC, this is displayed in the console:
    upload_2021-3-25_16-2-16.png
    And it displays an empty speech bubble.
     
  14. TonyLi

    TonyLi

    Joined:
    Apr 10, 2012
    Posts:
    12,706
    No errors or warnings before that?

    Temporarily set the Dialogue Manager's Other Settings > Debug Level to Info. Then play and reproduce the issue.

    In the Console, examine the lines that precede that error. Do you see this line?

    Dialogue System: Registering Lua function RandomElement

    If so, do you then see this line later in the Console?

    Dialogue System: Unregistering Lua function RandomElement

    If so, click on that line, press Ctrl+C to copy to the clipboard, then paste it into a reply here.
     
    Last edited: Mar 25, 2021
  15. Sicryn

    Sicryn

    Joined:
    Apr 18, 2018
    Posts:
    9
    Oh ! Indeed there is not! Weird ...
    This is all I have:
    upload_2021-3-25_16-20-25.png
     
  16. TonyLi

    TonyLi

    Joined:
    Apr 10, 2012
    Posts:
    12,706
    It's fine to not see "Registering Lua function RandomElement". The Dialogue System suppresses that message when it initializes. If you did see it, it would mean that something is trying to register it again, and that would be important to know.

    I was more interested to know if you saw "Unregistering Lua function".

    Let's double check something. Please add a Lua Console component to your scene. Then play the scene and press ~+L. This will open the Lua Console window. Enter:

    return RandomElement("foo|bar")

    Does it print "foo" or "bar", or does it report the same error in the Console?
     
  17. Sicryn

    Sicryn

    Joined:
    Apr 18, 2018
    Posts:
    9
    Same error apparently :(
    upload_2021-3-25_17-41-14.png

    Thanks for those quick replies by the way!
    And would you prefer that we go by email so as not to fill the forum too much?
     
  18. TonyLi

    TonyLi

    Joined:
    Apr 10, 2012
    Posts:
    12,706
    @Sicryn - Forum or email (tony (at) pixelcrushers.com) is fine. Does this problem occur in a new, empty project with the Dialogue System?

    I think you will need to send me a reproduction project.
     
  19. Sicryn

    Sicryn

    Joined:
    Apr 18, 2018
    Posts:
    9
    No, in a new empty project, the problem is not there, so it comes from my current project which must be problematic for one reason or another.
    I will try to do that then. I'll send it by email when it's ready.
     
    TonyLi likes this.
  20. Sicryn

    Sicryn

    Joined:
    Apr 18, 2018
    Posts:
    9
    Hi ! It's me ! Again :rolleyes:
    By preparing a lite version of the project to send it to you, I finally figured out what was causing the problem. Apparently when I instantiate the prefab of my Dialogue Manager, it does not work, but when it is directly in the scene, without the instantier, it works ...
    So now I know where it came from, but it's still weird because it used to work like that.
    With this info do you have any idea? Or is it still better that I send you the project?
     
  21. TonyLi

    TonyLi

    Joined:
    Apr 10, 2012
    Posts:
    12,706
    Hi @Sicryn - After instantiating your Dialogue Manager, call:
    Code (csharp):
    1. DialogueLua.RegisterLuaFunctions();
     
  22. TonyLi

    TonyLi

    Joined:
    Apr 10, 2012
    Posts:
    12,706
    Disco Elysium 20% Off in BAFTA Awards 2021 Sale - Includes Final Cut

    The multi-award-winning Disco Elysium, made with the Dialogue System for Unity, is currently on sale for 20% off. It also includes access to the Final Cut version releasing on March 30 with full English voiceover, new characters, etc.

     
  23. Sicryn

    Sicryn

    Joined:
    Apr 18, 2018
    Posts:
    9
    omg... Ok, it worked ! Thank you ! It really was that simple from the beginning haha... :eek:
    I'm so glad we were able to solve this, thanks man !
     
    TonyLi likes this.
  24. TonyLi

    TonyLi

    Joined:
    Apr 10, 2012
    Posts:
    12,706
    Disco Elysium - The Final Cut -- Out Now

    Disco Elysium - The Final Cut, the multi-award winning game of the year made with the Dialogue System for Unity, is out now with full voice acting and new quests and locations. Check out IGN's glowing 10/10 review:
     
  25. guybro_thunderboots

    guybro_thunderboots

    Joined:
    Aug 27, 2015
    Posts:
    45
    I think the demos need to be updated to work with the Unity's new input system. No controls work; I traced it through the code and see that it's scanning `InputDeviceManager.inputActionDict` when the new input system is enabled via USE_NEW_INPUT, but the demos don't actually call `RegisterInputAction` or `UnregisterInputAction` to populate `inputActionDict` so you can't really do anything other than summon the demo menu via the escape button.

    Alternatively, if we're supposed to set up the demos manually to use the new input system, it would be useful to have that documented somewhere in the quick start section: I haven't encountered any instructions to do that yet, so maybe they exist and I just haven't reached them yet?
     
  26. TonyLi

    TonyLi

    Joined:
    Apr 10, 2012
    Posts:
    12,706
    Hi @guybro_thunderboots - Since the vast majority of projects use Unity's built-in input manager, the demo works with built-in input by default. The upcoming release has a 'New Input System' subfolder with instructions on how to use it with the optional new Input System. I've attached a unitypackage with those files to this post.
     

    Attached Files:

  27. guybro_thunderboots

    guybro_thunderboots

    Joined:
    Aug 27, 2015
    Posts:
    45
    Setup was kind of awkward, but it works.

    Thanks!
     
  28. TonyLi

    TonyLi

    Joined:
    Apr 10, 2012
    Posts:
    12,706
    Glad to help! Some of those steps are mandatory, such as using InputSystemUIInputModule. The rest aren't; you can generally skip them in your own scenes/projects. It's just set up that way in the demo to make it easy to go back and forth between Unity input and the new Input System.
     
  29. SOSolacex

    SOSolacex

    Joined:
    Jan 10, 2018
    Posts:
    121
    Hey Tony,

    I was curious if it was possible to send messages through conversation? I reckon it's done through the scripting block, although I am not too knowledgeable in regards to how, even though I've read the documentation.
    With send messages, I mean basically the same thing you can do with the actions menu -> send message in the dialogue system trigger component.
    As to why; I basically have a script on locked doors that receive messages through certain actions/events and thus get unlocked as soon as they receive a message to unlock.

    This can probably be done in a more efficient/better way, but I am not adept at scripting, and making bool values per door and putting everything in update sounded inefficient to me, hence why I did it this way.

    Thanks in advance!
     
  30. TonyLi

    TonyLi

    Joined:
    Apr 10, 2012
    Posts:
    12,706
    Hi @SOSolacex - Yes, you can use the SendMessage() sequencer command in a dialogue entry node's Sequence field. For example, say a script on the GameObject named "Red Door" has a method Unlock(). To call that method:
    • Dialogue Text: "Unlock the red door."
    • Sequence: SendMessage(Unlock, , Red Door)
    (The second parameter to SendMessage() is an optional string to pass to the method. Since Unlock() doesn't take a string parameter, we just leave it blank.)

    Other options include writing a custom sequencer command, registering a C# method with Lua, or hooking up a scene-based UnityEvent.
     
    SOSolacex likes this.
  31. SOSolacex

    SOSolacex

    Joined:
    Jan 10, 2018
    Posts:
    121
    Oh.. it's in the sequencer field instead of script.. I am dumb. hahahah
    My bad, but thanks a lot. :oops:
     
  32. TonyLi

    TonyLi

    Joined:
    Apr 10, 2012
    Posts:
    12,706
    Glad to help!
     
  33. SOSolacex

    SOSolacex

    Joined:
    Jan 10, 2018
    Posts:
    121
    Got the camera and and sequencer etc to work after reading the documention! (Didn't realize it was there)
    However, I've currently ran into a bit more difficult problem.

    I am using Opsive's first person controller and ultimate inventory system, and I am not sure how I can make a script that would manage the effects of consumables upon use, that happen to change dialogue database variables/give camera effects.

    Would you be able to give me a few pointers in how to do this?
     
  34. TonyLi

    TonyLi

    Joined:
    Apr 10, 2012
    Posts:
    12,706
    Hi @SOSolacex - So when the player uses a consumable, it should change a dialogue database variable? If so, then in the consumable script, use DialogueLua.GetVariable() and/or DialogueLua.SetVariable(). (API: DialogueLua) Example:
    Code (csharp):
    1. public class AlcoholicBeverage : ItemObjectBehaviour
    2. {
    3.     public override void Use(ItemObject itemObject, ItemUser itemUser)
    4.     {
    5.         DialogueLua.SetVariable("Is Drunk", true);
    6.         Camera.main.GetComponent<WobbleEffect>().enabled = true;
    7.     }
    8. }
     
  35. TonyLi

    TonyLi

    Joined:
    Apr 10, 2012
    Posts:
    12,706
    @SOSolacex - You could generalize the script like this:

    Code (csharp):
    1. public class ItemBoolVariableSetter : ItemObjectBehaviour
    2. {
    3.     [VariablePopup] public string variable;
    4.     public bool value;
    5.  
    6.     public override void Use(ItemObject itemObject, ItemUser itemUser)
    7.     {
    8.         DialogueLua.SetVariable(variable, value);
    9.     }
    10. }
     
  36. kuromatu

    kuromatu

    Joined:
    Dec 27, 2019
    Posts:
    22
    I have two questions.
    Is it possible to put out background CG like a visual novel?
    Is it possible to skip text?
     
  37. TonyLi

    TonyLi

    Joined:
    Apr 10, 2012
    Posts:
    12,706
    Hi @kuromatu - Yes. In fact, the Dialogue System Extras page has a free visual novel starter framework addon for the Dialogue System that handles backgrounds, skip text, backtrack, history, and more.
     
  38. SOSolacex

    SOSolacex

    Joined:
    Jan 10, 2018
    Posts:
    121
    Hey, I started using this method.
    Sorry for taking so long to respond; Took me a while to figure things out. Apparently there was a bug in the UseItemActionSetAttribute script that prevented me from getting things to work.

    I ended up using this code
    Code (CSharp):
    1.     public class WeirdPotion : ItemAction
    2.     {
    3.         public int strengthIncrease = 5;
    4.         protected override bool CanInvokeInternal(ItemInfo iteminfo, ItemUser itemUser)
    5.         {
    6.             return true;
    7.         }
    8.  
    9.         protected override void InvokeActionInternal(ItemInfo itemInfo, ItemUser itemUser)
    10.         {
    11.             int playerStrength = DialogueLua.GetVariable("Strength").asInt;
    12.             playerStrength += strengthIncrease;
    13.             DialogueLua.SetVariable("Strength", playerStrength);
    14.         }
    15.     }
    ItemAction allowed me to see it in the item action list as custom action, hence why I started using that. (Followed inventorysystem documentation)

    I'll admit ItemObjectBehaviour might have been better, but I suck so hard at scripting that I wasn't sure what the difference was. So I just changed to ItemAction since it worked in the editor. :D
     
    TonyLi likes this.
  39. TonyLi

    TonyLi

    Joined:
    Apr 10, 2012
    Posts:
    12,706
    Dialogue System 50% Off - Version 2.2.16 Released

    The Dialogue System for Unity is 50% off in the Asset Store's Sprint Into Spring Sale!

    Use coupon code SPRING2021 on orders of $100 or more for additional savings.


    Version 2.2.16 has been released and should be available on the Asset Store soon. This is another big update with new features, performance improvements, and bug fixes. Highlights include:
    • Dialogue Editor's Actors, Quests/Items, Locations, and Variables sections are now approximately 2x faster.
    • Dialogue Editor's Conversations > Outline mode now uses a reorderable list for easier reordering.
    • Quality of life improvements to articy:draft and Ink support.

    Version 2.2.16:

    [Core]
    • Changed: Duplicating / copy-pasting dialogue entries does not duplicate scene event if original entry has scene event.
    • Added: [autocase=variable] tag.
    • Added StandardDialogueUI.ForceOverrideSubtitle/MenuPanel().
    • Added: DialogueManager.customResponseTimeoutHandler delegate, called if Response Timeout Action is set to Custom.
    • Improved: Dialogue System Trigger > Run Lua Code sets Variable["Actor"]/Variable["ActorIndex"] to interactor.
    • Improved: Quest entries editor now has compact view option.
    • Improved: Mouse hover over dialogue entry nodes now shows link order.
    • Improved: Text type custom template fields now use multi-line text edit areas in main inspector area.
    • Improved: Added StandardUISubtitleControls.OverrideActorPanel(DialogueActor).
    • Improved: StandardUISubtitleControls.OverrideActorPanel can now specify a custom panel.
    • Improved: Added activeConversation property to DialogueManager.instance and Subtitle object.
    • Improved: Demo scene: Added option to use new Input System.
    • Improved: Removed Chat Mapper-specific fields from default dialogue database template to significantly reduce asset size.
    • Improved: Dialogue Editor Outline mode now uses reorderable list.
    • Improved: StandardUIMenuPanel.InstantiateButton() is now virtual.
    • Improved: Sequencer doesn't touch camera until needed (e.g., by Camera() or Zoom2D() sequencer command).
    • Improved: Localization export/import has options to use key field (e.g., "Articy Id") and include conversation title for context.
    • Improved: Asset Renamer window can now also rename actors and quests.
    • Fixed: If audio sequencer command automatically adds Audio Source, Play On Awake & Loop are now set false.
    • Fixed: Standard Bark UI hide duration now observes Dialogue Manager's Dialogue Time setting.
    • Fixed: VN Template Dialogue UI's Portrait Name animation.
    • Fixed: VN Template Dialogue UI & SMS Dialogue UI prefabs set fixed size portrait images to prevent distorted scaling.
    • Fixed: Improved sanitizing of conversation titles in Dialogue Editor's conversation selection dropdown.
    • Fixed: Delay() sequencer command ignored Time.timeScale when dialogue time mode was set to Gameplay.
    • Fixed: DialogueManager.LoadAsset() from addressables handles multiple addressables simultaneously.
    • Fixed: Cursor position issue when double-clicking node to open quick text entry box.
    • Fixed: Animator will no longer report warning if trying to play portrait animations for an actor that doesn't have a portrait animator controller.
    • Fixed: SetContinueMode() could fail with error with certain override settings.
    • Fixed: Lua now clears error stack after every call to reduce memory use.
    • Fixed: StandardUISubtitlePanel didn't observe when Deactivate On Hidden checkbox was unticked.
    • Fixed: IncrementOnDestroy now doesn't increment if being destroyed by DestructibleSaver while applying save data.
    • Fixed: Issue with Dialogue Editor not updating inspector after maximizing docked window and then un-maximizing it.
    • Fixed: Selector/ProximitySelector: Calls OnDeselect() event on previous usable if switching immediately to new usable.
    • Fixed: When subtitle was set to Accumulate Text, TextMeshProTypewriterEffect did not handle <font> tags with non-alpha characters.
    • Fixed: StandardUIResponseButton.OnClick no longer adds click event at runtime if another event is already assigned.
    • Fixed: If another conversation starts for dialogue UI while it's playing close animation, it cancels close and re-shows UI.
    • Updated: Updated alternative support for NLua.
    • Text Table: No longer counts empty field as having text for a language.
    • Save System: Added MultiEnabledSaver.
    • Save System: AnimatorSaver now also saves trigger parameter values.
    • Save System: ConversationStateSaver waits for dialogue UI animation if switching conversations on load.
    • Save System: Fixed: Doesn't delete non-cross-scene data when loading additively.
    • Save System: Fixed: Calls BeforeSceneChange() on scene objects UnloadAdditiveScene().

    [Third Party Support]
    • Adventure Creator: Updated for 1.73.
    • articy:draft: Importer now handles articy:expresso ++ and -- syntax; updated localization importer to use separately-downloaded, open source Unity-QuickSheet library.
    • Ink: When using INK_FULLPATHS with nested includes, entrypoint picker now groups submenus more nicely.
    • Inventory Engine: mmAddItem() can now load items from addressables.
    • Lively Chat Bubbles: Added Lively Chat Bubbles Bark UI.
    • Ultimate Character Controller: Updated for 2.3.2. Updates to Lua functions.
    • Ultimate Inventory System: Updated for 1.1.6.
     
    Last edited: Apr 12, 2021
    DMRhodes likes this.
  40. Stickeyd

    Stickeyd

    Joined:
    Mar 26, 2017
    Posts:
    174
  41. schneckerstein

    schneckerstein

    Joined:
    Dec 6, 2018
    Posts:
    36
    Hey there!

    Is there any way to get an event for changes to the Lua Item table?

    I'm bulding an inventory system, and I want to update the UI on changes. I've tried
    Code (CSharp):
    1. DialogueManager.AddLuaObserver("Item", LuaWatchFrequency.EveryUpdate, OnInventoryChangedHandler);
    but that doesnt do anything. Any ideas?
     
  42. TonyLi

    TonyLi

    Joined:
    Apr 10, 2012
    Posts:
    12,706
    Hi @Stickeyd - Looks like you added a response node "Let's go to the disco." ;)

    When this happens, open an Animator window and inspect the UI panel or whatever UI element manages the darkening effect. Keep an eye on its animator parameters. Maybe the parameters are being set incorrectly, or they're not resetting properly.

    Also, consider importing the updated VN Template Dialogue UI and corresponding animations and animator controller located in ...Dialogue System / Prefabs / Art / Animation / Portrait Animator from version 2.2.16, which just released today. The animations and animator controller were updated to be more robust in different situations.

    Hi @schneckerstein - If possible, don't use Lua observers every update. That can be a huge drag on performance. I recommend registering C# methods with Lua. (There's a video tutorial at the top of that link.) That way you can use them in Lua (e.g., conversations and Dialogue System Triggers) and in C# (e.g., your own scripts).

    Say you have a C# method to increase the amount of an item. You can call OnInventoryChangedHandler in this method. You can track the items in the Dialogue System's Item[] Lua table or in C#. Here's an example that uses Lua and the DialogueLua C# class:

    Code (csharp):
    1. public event Action OnInventoryChanged;
    2.  
    3. public void AddItem(string itemName, int amountToAdd)
    4. {
    5.     int currentAmount = DialogueLua.GetItemField(itemName, "Amount").asInt;
    6.     int newAmount = currentAmount + amountToAdd;
    7.     DialogueLua.SetItemField(itemName, "Amount", newAmount);
    8.     OnInventoryChanged();
    9. }
    If it's registered with Lua, you can use the Script field's "..." menu to add an item in a conversation:

    upload_2021-4-13_8-46-10.png

    You can also the method in your own C# scripts:

    Code (csharp):
    1. myInventory.AddItem("Apple", 3);
    In both cases, the OnInventoryChanged() event will be called.
     
    schneckerstein likes this.
  43. TonyLi

    TonyLi

    Joined:
    Apr 10, 2012
    Posts:
    12,706
    Version 2.2.16 of the Dialogue System for Unity is now live on the Asset Store!

    As with any package or update, back up your project before importing.

    Note: Version 2.2.16 has a change to response menus. If your response buttons' OnClick() events have any events assigned, the Dialogue System will not automatically configure them at runtime to call StandardUIResponseButton.OnClick. This allows designers to assign functionality other than the default click-to-select-response behavior, instead of in addition to the behavior. If your response buttons don't seem to be responding, make sure they don't accidentally have an empty event assigned, such as:
    upload_2021-4-13_9-44-6.png
    If they do, simply remove the event.

    upload_2021-4-13_9-37-57.png

    Reminder: The Dialogue System is currently 50% off in the Sprint Into Spring Sale.

    The Quest Machine and Love/Hate are also 50% off.
     
  44. TonyLi

    TonyLi

    Joined:
    Apr 10, 2012
    Posts:
    12,706
    Dialogue System-powered Games At LudoNarraCon Next Week

    Check out LudoNarraCon next week. It's the big convention for narrative games, and several games made with the Dialogue System are exhibiting there, including Disco Elysium, Lake, and Suzerain, and play some early access demos!

    upload_2021-4-13_15-49-50.png
     
  45. kuromatu

    kuromatu

    Joined:
    Dec 27, 2019
    Posts:
    22
    Thank you for your reply!
    Is it possible to call a visual novel by interacting after integrating the corgi engine?
     
  46. TonyLi

    TonyLi

    Joined:
    Apr 10, 2012
    Posts:
    12,706
    Yes, absolutely. Use the Corgi integration to interface the Dialogue System with Corgi. Instead of using overhead bubble UIs as in the integration's example scene, assign the VN Template Standard Dialogue UI to the Dialogue Manager GameObject's Dialogue UI field. If you have any questions about that, let me know here, or on the Pixel Crushers forum, or discord.
     
  47. Juan_Luis

    Juan_Luis

    Joined:
    May 10, 2016
    Posts:
    5
    Hello, i have a question.

    I can have a server with a csv (I don't know it's content, actors, etc... but with a format for import) and in the gameplay download the file and generate all the dialogue system?

    thx
     
  48. kuromatu

    kuromatu

    Joined:
    Dec 27, 2019
    Posts:
    22
    Sorry for the basic question. I have two questions.
    When I tried to assign the VN Template Standard Dialogue UI to the Dialogue UI field of the DialogueManagerGameObject, I was given the choice of add instance or usePrehab. Which one should I choose?

    Where are the npc conversations? When I opened edit in the dialog manager and opened conversations, nothing was written.
     
  49. TonyLi

    TonyLi

    Joined:
    Apr 10, 2012
    Posts:
    12,706
    Hi @Juan_Luis - It's easiest if your server has an XML or JSON file. It can be in Chat Mapper XML, articy:draft XML, or Twine twison JSON format. You can import it with a single line of code, such as this for articy:draft XML:
    Code (csharp):
    1. var database = ArticyConverter.ConvertXmlDataToDatabase(xmlData);
    If you want to import any other format, such as CSV, see How To: Create Database At Runtime. Or, if it's already in the Dialogue System's DialogueDatabase JSON format, you can import it like this:
    Code (csharp):
    1. var database = JsonUtility.FromJson<DialogueDatabase>(jsonText);

    Hi @kuromatu - Either is fine, but I recommend Add Instance. This will add an instance to the Dialogue Manager's Canvas that you can customize more easily.

    You must write the conversations. If you want some example conversations to experiment with, you can assign the demo's Demo Database to the Dialogue Manager. See the Quick Start Tutorial to learn how to write conversations.
     
    Last edited: Apr 14, 2021
  50. Juan_Luis

    Juan_Luis

    Joined:
    May 10, 2016
    Posts:
    5
    TonyLi likes this.