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. katie-muller

    katie-muller

    Joined:
    Feb 18, 2014
    Posts:
    18
    Wow, thank you so much for the fast, thorough response! This tremendously cleared things up for me going forward, and the pictures were a huge help. :D
     
  2. TonyLi

    TonyLi

    Joined:
    Apr 10, 2012
    Posts:
    12,697
    Happy to help! The Dialogue System is a bigger beast than Love/Hate, with a lot of handy little features that can go unnoticed. If you ever have a question about the workflow, just post here or email tony (at) pixelcrushers.com. For example, my previous post used the GameObject name "Bob" in the Conditions and Script fields. The Dialogue System automatically sets the variables "Actor" and "Conversant" when a conversation starts. So you could make it more generic like this:
    • Conditions: GetHappiness(Variable["Conversant"]) >= 50
     
  3. katie-muller

    katie-muller

    Joined:
    Feb 18, 2014
    Posts:
    18
    That makes a lot of sense, and it sure is! I appreciate all the kindness and patience. I actually have one more question for you, if you don’t mind. How do you set up Conversation Triggers (OnUse) for a 2D point and click game? Meaning, how can you activate Conversation Triggers based on mouse movement/clicks? I'll attach a picture of what my game looks like currently to give you a better idea.

    My project is a 2D (isometric) game (using Ultimate Isometric Toolkit) where the player clicks and interacts with the characters on the screen. I’m aiming to have it so when the cursor is over the character, the character highlights, and then clicking that character triggers their conversation. I’ve seen plenty of examples of Dialogue System in 3D games, including the tutorials, but haven’t seen anything based in 2D.

    What I’ve tried is using the NPC/Player Wizards to set up a “player” object and one of my NPCs, setting Interactive Conversations to true with trigger “OnUse”, and making sure the Conversation Trigger and Character Controller are attached to the NPC. I’ve followed this as well: http://www.pixelcrushers.com/dialogue_system/manual/html/faq.html#faqTriggers

    I’m not sure if I’m approaching this the right way, since my game technically doesn’t really have a player character that moves around the scene. :confused:
     

    Attached Files:

  4. TonyLi

    TonyLi

    Joined:
    Apr 10, 2012
    Posts:
    12,697
    Here's a link to a 2D example that sounds like it's similar to your scenario: 2DClickTriggerExample.unitypackage

    I haven't used Ultimate Isometric Toolkit. I see it has its own physics components. Hopefully they also register as regular physics components. If not, you could try to set up something similar using the toolkit's physics.

    To set up the example scene, I manually added a BoxCollider2D (any 2D collider will do), a Usable, and a Conversation Trigger:



    I added an empty GameObject to the scene for the player. It has a Selector and a Set Component Enabled On Dialogue Event. The Selector is configured to select at the mouse position. I changed the Use Button to Fire1, which is typically the left mouse button. The Set Component Enabled On Dialogue Event component disables the Selector during conversations. To keep the screenshot small, I collapsed the "On End" foldout, but it's configured similarly to "On Start":



    I also added a Unity UI Selector Display, and added a UI Selector Panel to the Dialogue Manager's Canvas, so I could customize the selector using Unity UI if I chose to in the future.

    A lot of devs work on games that don't use Unity's physics, or at least not in the regular way. In these cases, they usually set up a Conversation Trigger and call OnUse() manually, or even manually call DialogueManager.StartConversation() in a script. If your toolkit prevents you from using the built-in Selector script, you can fall back to doing the same thing.
     
    katie-muller likes this.
  5. TonyLi

    TonyLi

    Joined:
    Apr 10, 2012
    Posts:
    12,697
    I forgot to answer about character highlighting. If you want to show an icon or something over the character, you can add a Usable Unity UI component and assign some UI elements. If you want to actually highlight the sprite (for example using an asset like this), you can either:
    • Hook into Selector's SelectedUsableObject and DeselectedUsableObject events (see the API), or
    • Configure the sprite so it highlights when the mouse hovers, independently of the Dialogue System. If this is controlled by a script, you can add that script to Set Component Enabled On Dialogue Event to turn it off during conversations.
     
    katie-muller and Mazak like this.
  6. katie-muller

    katie-muller

    Joined:
    Feb 18, 2014
    Posts:
    18
    Thank you for all your help again! I understand your answer and tried applying it to my project. Sadly nothing happens when I hover my mouse over my own characters like in your example, but I think it's due to my toolkit I'm using. I'm going to try the manual approach like you mentioned =)

    UPDATE: I've got it working! Just in case there is anyone else out there using the Ultimate Isometric Toolkit like I am alongside Dialogue System, I manually called the conversation through a raycasting script (I checked if the collider the raycast returns with matches the name of the character hit). But, since UIT uses a different coordinate system for isometric spaces, it means you have to rotate the ray as well, which is where my problem was :oops: Page 8 of UIT's QuickGuide explains how you can get your raycast to cast in isometric spaces :D
     
    Last edited: Feb 11, 2017
    TonyLi likes this.
  7. Hormic

    Hormic

    Joined:
    Aug 12, 2014
    Posts:
    251
    Hey TonyLi, Thank you for your effort and help!!, Yes it was in the demo scene, but i will examine this problem tomorrow more closely, because when you can't reproduce it, it must be on my end.

    One Question:
    Do you think it is possible to dress your own rfps bookexample which is technically working perfectly and well integrated in the DS Dialogstructur, similar to the bookreader asset? Cause then it would be better, to put the effort in styling your bookexample instead of using the bookreader asset.
     
  8. TonyLi

    TonyLi

    Joined:
    Apr 10, 2012
    Posts:
    12,697
    Hi @Hormic - Here's a version of the book example that points to BookReader's textures. (I didn't include BookReader's textures themselves, so that asset must also be imported.)

    RFPSBook_withBookReader_2017-02-12.unitypackage

    It also includes a short subclass of UnityUIDialogueUI that adds support for left and right pages. In your Dialogue Text, put the string "{break}" between the left and right page text. For example:
    • Dialogue Text: This is the left page text.{break}And this is the right page text.
     
    Hormic likes this.
  9. katie-muller

    katie-muller

    Joined:
    Feb 18, 2014
    Posts:
    18
    I'm back with another question! :p I've started to follow along with your Lua example, and I was able to make a C# command into Lua so I can use it in the Dialogue System. Everything is working like a charm, but it seems like my condition is being called at the start of the conversation instead of that the node I want it to be at.

    Here is how I structured it. The condition is only attached to the "Attack Enemy" node:


    So I registered a bool in Lua, so that when I call that condition, it registers a bool in my character's AI script to true. Then in my character's AI script, it checks if the bool is true, and calls a function. For now, I just have a debug.log in that function, displaying "override" in my console.

    When I play the scene, I don't get the "override" debug.log in my console, so all is working fine. However, once I select my character, it immediately calls the "override" debug.log, as if my bool is immediately being set to true somehow when I select her, instead of when I click on "Attack Enemy". :confused:
     
  10. TonyLi

    TonyLi

    Joined:
    Apr 10, 2012
    Posts:
    12,697
    Hi @katie-muller - In your screenshot, there's also a [condition] on the START node. Could this be calling your Lua function?

    Also, the function name SetAttackEnemyOverride sounds more like an action than a condition. Should you move it to the Script field instead of the Conditions field?

    The Script field only executes when the node is played (i.e., when the player selects the response "Attack enemy!").

    The Conditions fields, on the other hand, are executed before then, to determine which link destinations are valid. In fact, Conditions fields are evaluated one level earlier than most people expect. It has to do this to handle certain continue button modes. For a detailed explanation with a screenshot, please see Conversations Evaluate Conditions One Extra Level Ahead.

    I think if you just move SetAttackEnemyOverride("Kyla",true) to the Script field, it should work as you expect. However, it's probably worth reading over the link in the previous paragraph, too.
     
    katie-muller likes this.
  11. katie-muller

    katie-muller

    Joined:
    Feb 18, 2014
    Posts:
    18
    Yup, that worked! =) I had to place my Lua command into the script field. Thanks for the link and explaining! I'm going to read it now.
     
    TonyLi likes this.
  12. Hormic

    Hormic

    Joined:
    Aug 12, 2014
    Posts:
    251
    Awesome, thank you very much!!
    Unfortunately my problems are not over, i have the same behavior with this new demo as with the other bookreader demo - 2nd time i open the book i don't come in the mousemode.
    (I have no problem with your original RFPS - Bookdemo, there it works fine)
    But in your new demo i got an warning message which maybe shows what is wrong, seems closing the book is not executed in the right way. But i wonder cause now the bookreader scripts are not used, so i guess i have screwed somehing withhin the DS setup.

    Here is the message:
    edit problem solved:
    i think i have discovered what is the reason, i had a lot of components 2 or 3 times on the player and camera prefab and i deleted them that they are only one time there.
    On your original demo the player prefab is not changed, therefore there are 2 selectors on the camera and also the FPS player have scripts twice but here it works. ???
     

    Attached Files:

    Last edited: Feb 13, 2017
  13. TonyLi

    TonyLi

    Joined:
    Apr 10, 2012
    Posts:
    12,697
    Hi @Hormic - Try this:

    1. Remove the duplicate components.

    2. On FPS Player, remove the Set Active On Dialogue Event and Set Enabled On Dialogue Event components.

    3. Select menu item Component > Dialogue System > Third Party > Realistic FPS Prefab > Disable Gameplay In Conversations.


    This is what I think happened:

    • The demo scene uses the FPS Main prefab. The scene instance adds the Dialogue System components (Selector, etc.). Let's call this instance of the Selector component "Selector Y".
    • At some point, you may have added the Dialogue System components (Selector, etc.) to an FPS Main instance in one of your own scenes. Let's call this instance of the Selector component "Selector X". And then you may have applied the scene instance back to the prefab, meaning the prefab FPS Main now includes Selector X.
    • So when you load the demo scene, the FPS Main prefab includes Selector X. But the scene instance specifies to add Selector Y also. So you end up with two Selector components.
    This isn't normally a problem, except Set Enabled On Dialogue Event is configured to disable a specific Selector instance. The solution is to make sure that there's only one instance of everything, and that the Set XXX On Dialogue Event components correctly point to the instances.
     
    Hormic likes this.
  14. Hormic

    Hormic

    Joined:
    Aug 12, 2014
    Posts:
    251
    Thank you Tony, yes make absolutely sense that is the reason, but the wired things are not over now.
    For sure i have used the Disable Gameplay in Conversations Component before, but now i can't find it.
     

    Attached Files:

  15. TonyLi

    TonyLi

    Joined:
    Apr 10, 2012
    Posts:
    12,697
    Hi @Hormic - It's a menu item: Component menu > Dialogue System > Third Party > Realistic FPS Prefab > Disable Gameplay In Conversations. It has to be a menu item because it can potentially add several components, not just one.
     
    Hormic likes this.
  16. Hormic

    Hormic

    Joined:
    Aug 12, 2014
    Posts:
    251
    Hey Tony, Yes i know, and i used it before, but currently its not available in my project.
    Is it in the dll file?
    Seems my project has a problem opening the dll? I have this warning:
     

    Attached Files:

  17. TonyLi

    TonyLi

    Joined:
    Apr 10, 2012
    Posts:
    12,697
    It's in the unitypackage Assets / Dialogue System / Third Party Support / Realistic FPS Prefab Support.unitypackage. Try downloading and importing the latest version of the package from the Dialogue System Extras page.
     
  18. Hormic

    Hormic

    Joined:
    Aug 12, 2014
    Posts:
    251
    Hey TonyLi, big thanks again, but i had this latest package already installed, so unity says "nothing to import" when i try it again. Sorry that this whole story turns out so troublesome. :rolleyes:
     
  19. TonyLi

    TonyLi

    Joined:
    Apr 10, 2012
    Posts:
    12,697
    No worries! We'll get it working. Are there any red compiler errors in the Console window? These may prevent Unity from updating its menu items.
     
  20. Hormic

    Hormic

    Joined:
    Aug 12, 2014
    Posts:
    251
    You know what, now it is there and i have no idea why. I haven't changed anything in the project, except that i tryed to reimport the RFPS Asset you mentioned, what wasn't working regarding the message - nothing to import.....

    Ok, so now you mean i should delete all duplicates from FPS Camera and FPS Player, before i run the script.
    Do you mean just the duplicates (only one selector and leave the other and only one Set active on dialog event) or all (delete two selectors and two set active on dialog event and all duplicates completely)?
     

    Attached Files:

  21. TonyLi

    TonyLi

    Joined:
    Apr 10, 2012
    Posts:
    12,697
    Delete all Dialogue System-related components, except leave one Selector. Then run that menu item. That should hopefully do it! :)
     
  22. Hormic

    Hormic

    Joined:
    Aug 12, 2014
    Posts:
    251
    YESS!! Big thank you again, your support is outstanding and way above what someone could think off in there wildest dreams!! THX :)
     
  23. TonyLi

    TonyLi

    Joined:
    Apr 10, 2012
    Posts:
    12,697
    Happy to help!
     
    Hormic likes this.
  24. TonyLi

    TonyLi

    Joined:
    Apr 10, 2012
    Posts:
    12,697
    Check out No Truce With The Furies

    Kotaku posted a nice little article on ZA/UM's upcoming No Truce With The Furies, which uses the Dialogue System:
    Rock, Paper, Shotgun writes:
    No Truce With The Furies is also in the starting lineup of Humble Bundle's new publishing arm. Congratulations to ZA/UM for a great looking game!

     
    Veljo_Hagu and Hormic like this.
  25. TonyLi

    TonyLi

    Joined:
    Apr 10, 2012
    Posts:
    12,697
    Stranger Games' Visual Novel for Dialogue System Now Available

    Stranger Games' Visual Novel for Dialogue System was just released on the Asset Store! You can pick it up for 40% off right now while it's in beta.

    This is a third-party visual novel framework built on top of the Dialogue System. (You must also own a license for the Dialogue System to use it.) You can use it to make traditional visual novels or incorporate visual novel elements into other types of gameplay. It also includes support for Spriter and Live2D!

     
    BackwoodsGaming likes this.
  26. Duffer123

    Duffer123

    Joined:
    May 24, 2015
    Posts:
    1,216
    @TonyLi ,

    Hi. Is this asset still being developed? Also is it compatible with the new Articy : Draft 3?

    Also is it likely this Asset will be on sale anytime soon?
     
  27. TonyLi

    TonyLi

    Joined:
    Apr 10, 2012
    Posts:
    12,697
    Hi @Duffer123 - Absolutely. Features recently added for the upcoming v1.6.8 release include improvements to Unity UI support (such as an option for multiple randomized audio clips on the typewriter effect) and updates to the third party support packages for ORK Framework, Realistic FPS Prefab, S-Inventory, Opsive's Third Person Controller, and more. It also adds some nice features for programmers such as [LuaWizard] attributes so you can incorporate Lua wizards in your own scripts.

    Yes. We participated in the beta test of articy:draft 3. The Dialogue System is compatible with articy:draft 1.x, 2.x, and 3.x. It doesn't use Nevigo's new articy-to-Unity importer package, since the Dialogue System has been able to import articy since 1.x. However, I'm evaluating whether Nevigo's importer package may be useful to Dialogue System users.

    It's up to Unity. I've requested inclusions in any upcoming sales on the Asset Store.
     
    Last edited: Feb 20, 2017
  28. Duffer123

    Duffer123

    Joined:
    May 24, 2015
    Posts:
    1,216
    @TonyLi ,

    Excellent. Thank you for getting back to me so quickly. Hoping for a sale soon as think I missed the last one... ;)
     
  29. TonyLi

    TonyLi

    Joined:
    Apr 10, 2012
    Posts:
    12,697
    Feel free to use the evaluation version in the meantime if you like: Evaluation Version

    It's fully compatible with the paid Asset Store version and includes all features. It just has a watermark and doesn't include the source code.
     
  30. Duffer123

    Duffer123

    Joined:
    May 24, 2015
    Posts:
    1,216
    Thanks. Will do.
     
  31. TonyLi

    TonyLi

    Joined:
    Apr 10, 2012
    Posts:
    12,697
    I'll be traveling Friday, February 24, through Sunday, February 26, 2017. I'll do my best to reply to support requests quickly, but responses may take a little longer than usual.
     
    Hormic likes this.
  32. TonyLi

    TonyLi

    Joined:
    Apr 10, 2012
    Posts:
    12,697
    State of Extinction on Steam

    Check out Stone Pixel Games' State of Extinction, made with the Dialogue System. It's available in Early Access on Steam:

     
    BackwoodsGaming likes this.
  33. TonyLi

    TonyLi

    Joined:
    Apr 10, 2012
    Posts:
    12,697
    Keep your eye on the Asset Store on Monday....
     
    AGregori likes this.
  34. Duffer123

    Duffer123

    Joined:
    May 24, 2015
    Posts:
    1,216
  35. TonyLi

    TonyLi

    Joined:
    Apr 10, 2012
    Posts:
    12,697
    Dialogue System in Asset Store Wishlist Sale

    The Dialogue System for Unity is on sale right now in the Asset Store's Wishlist Sale! If you don't already have a copy, you can pick it up on sale. Several other great assets are featured in the sale, too. And the Dialogue System has integration packages for many of them, including Adventure Creator, Behavior Designer, Opsive's Third Person Controller, and Corgi!
     
    Last edited: Feb 27, 2017
    BackwoodsGaming likes this.
  36. TonyLi

    TonyLi

    Joined:
    Apr 10, 2012
    Posts:
    12,697
    TextMesh Pro Now Free (& Dialogue System Has Support Package)

    Digital Native's TextMesh Pro is now free and will be integrated into Unity!

    TextMesh Pro's text looks much sharper than Unity's built-in UI Text, and it comes with a ton of options such as inline images, inline links, and lots of advanced visual effects.

    And the Dialogue System includes a TextMesh Pro Support package of course! ;)

    I use TextMesh Pro in all of my own projects. The crispness difference is especially noticeable in world space text.
     
  37. SpectralRook

    SpectralRook

    Joined:
    Feb 9, 2014
    Posts:
    112
    @TonyLi, If you have the time, could you look at a new asset called, Ultimate Survival for possible integration with Dialogue System. The developer has a forum post for support here.
     
  38. TonyLi

    TonyLi

    Joined:
    Apr 10, 2012
    Posts:
    12,697
    Hi @SpectralRook - I'll add it to the list to write an integration as soon as time allows. In the meantime, if anyone else writes an integration I'll be happy to host it on the Dialogue System Extras page. Briefly, you'll probably want to do the following:
    1. Write a script for the player GameObject that pauses Ultimate Survival's controller and camera in OnConversationStart() and resumes in OnConversationEnd(). (Or add a Set Component Enabled On Dialogue Event component.)
    2. Write a script that registers Lua functions to get and set Ultimate Survival values such as health and items.
    3. When Ultimate Survival introduces save & load, use PersistentDataManager.GetSaveData() and ApplySaveData() to include the Dialogue System's data in Ultimate Survival's saved games.
     
  39. Duffer123

    Duffer123

    Joined:
    May 24, 2015
    Posts:
    1,216
    @TonyLi,

    Just (finally) purchased this asset.

    Would imagine integration with PGI inventory should be fairly straightforward but would welcome your thinking on that as imagine its not high on your list of planned integrations (and a fresh version of PGI is due out v soon)...
     
  40. TonyLi

    TonyLi

    Joined:
    Apr 10, 2012
    Posts:
    12,697
    Hi @Duffer123 - Thanks!

    I won't have time for a couple of weeks to write an official integration, but it should be fairly straightforward. If you get stuck on anything, please let me know. Like my previous post, you'll want to register Lua functions to manipulate the inventory. Then you can call those Lua functions in your conversations -- for example, something like:
    • Dialogue Text: "You're out of health potions. Here, take this one."
    • Conditions: ItemCount("Health Potion") == 0
    • Script: GiveItem("Health Position")
    Use PersistentDataManager to serialize the Dialogue System's data into a string that you can add to PGI's XmlSerializer. Or, to go the other way (that is, to use the Dialogue System as the main save/load system), write a persistent data component that stores PGI's XML output in the Dialogue System. Either way, I recommend first getting familiar with the Dialogue System in general, then get the Lua functions set up, and finally tackle save/load once everything else is working smoothly.

    To see an example, the last download button in the Extras section of the Dialogue System Extras page contains an example integration for Inventory Master, which is free. (Or download direct here: Inventory Master Integration.) Or import the integration packages (in the Third Party Support folder) for S-Inventory or Inventory Pro. They won't compile without those inventory systems installed, but you can at least peek into the integration code.
     
  41. Duffer123

    Duffer123

    Joined:
    May 24, 2015
    Posts:
    1,216
    @TonyLi ,

    Thanks. Just reading and watching my way in to this Asset. Rather overwhelmed with possibilities at moment! PGI is releasing a Unity 5.5+ update shortly so probably worth waiting for that before building an integration...

    I'm making an RPG which is item, detail and stat rich. In fact you helped me a lot in the past with scriptableobjects and gameobjects and i went largely the GO (per item or stat) route to allow for heavy customisation. Unfortunately, Inventory Pro doesnt play well with sockettable and modifiable items through to save/load and, although it now has stats they are one big list with no sub categories etc. It's easier to say tie my item GOs to PGI...

    Speaking of which, using additional actor variables in your Asset may be a way to go with player stats etc but again it could be a long unwieldy list (attributes, points, modifiers, vitals, abilities, classes, race etc). Would welcome your thoughts on best way to go with that now with your Dialogue System integrated too?
     
  42. TonyLi

    TonyLi

    Joined:
    Apr 10, 2012
    Posts:
    12,697
    The Dialogue System is a comprehensive product. Take your time digging into its features, and of course post here or email tony (at) pixelcrushers.com if you have any questions. It's often quicker than digging through the large manual.

    You can certainly use actor variables and access them in your own script using DialogueLua.GetActorField() and DialogueLua.SetActorField(). (If you localize actor fields, use DialogueLua.GetLocalizedActorField() etc. to access the localized version for the current language.) The advantage is that they're automatically included in the Dialogue System's saved game data. And of course they're easy to access in conversations and quests this way. One disadvantage, though, is that they're not exposed in Unity's Inspector view this way.

    Another factor may be the Dialogue Editor interface for actor fields. It's entirely serviceable as-is, but changing to reorderable lists has been on my personal wishlist for a while. In a patch coming out next week, the Variables section will use reorderable lists, but the remaining sections will continue to use the existing interface until I have time to change them.
     
  43. Duffer123

    Duffer123

    Joined:
    May 24, 2015
    Posts:
    1,216
    @TonyLi ,

    That sounds great - the re-orderable lists thing in Variables - would that also apply to local/other variables against Actors in the editor. If there was some way to type/subtype them that would be amazing... (but appreciate that may be asking for a whole lot more - ! - unless there is an easy work around)?

    [edit]

    Presumably you can in any event reference Actor level (local or other) variables in the Script and Condition fields (as well as global Variables in this Asset)?
     
  44. TonyLi

    TonyLi

    Joined:
    Apr 10, 2012
    Posts:
    12,697
    In a dialogue database, every "thing" (actor, quest, conversation, etc.) has a list of fields. Each field has a name, value, and data type. There are several built-in data types, such as Text, Number, Quest State, etc. And you can also define your own custom field types. But (sorry, there's always a "but", isn't there?), internally every value is stored in the dialogue database as a string. (At runtime, Numbers go into the Lua environment as actual numbers, so there's no strange runtime string-to-number conversion.)

    Yes. You can type it into Script and Conditions fields manually, such as:
    Code (Lua):
    1. Actor["Player"].Age >= 21
    or select actor fields from the Lua wizards' dropdown menus if you prefer to just point and click.
     
  45. Duffer123

    Duffer123

    Joined:
    May 24, 2015
    Posts:
    1,216
    @TonyLi ,

    Thanks - that really helps.

    I suppose I could create plenty of my own custom field types (I can live with them being, in reality, strings) like Stat-Attribute, Stat-Point, Ability-Skill, Element-Prime - that sorta thing - and they could/would all be saved in and out.

    Hell, noting that, wondering if I could use this Asset as a sort-of Inventory too! ;)

    [edit] - Good grief, hand't got around to looking at the Lua Wizard - it's amazing.

    [edit] - in the custom field type, if I am creating say an Attribute Type with a number value, do I still use this bit of code:-
    Code (CSharp):
    1. public override string Draw(string currentValue, DialogueDatabase database) {
    2.             return EditorGUILayout.TextField(currentValue);
    or do I change it to:-
    Code (CSharp):
    1. public override float Draw(float currentValue, DialogueDatabase database) {
    2.             return EditorGUILayout.TextField(currentValue);
    ?
     
    Last edited: Mar 5, 2017
  46. TonyLi

    TonyLi

    Joined:
    Apr 10, 2012
    Posts:
    12,697
    Thanks! It's useful for the basic stuff, but it doesn't automatically pull in your custom Lua functions, just the built-in data structures.

    Sorry, what's the difference between those code blurbs? There's a sort of made-up example in Scripts/Editor/Custom Field Types for selecting "game modes" from a dropdown. It might be a helpful model.
     
  47. Duffer123

    Duffer123

    Joined:
    May 24, 2015
    Posts:
    1,216
    @TonyLi ,

    So if the value of my Attribute types was a float or int - should I change it from public override string to public override int or float and should it be Draw(string... or Draw(int/float... ?
     
  48. TonyLi

    TonyLi

    Joined:
    Apr 10, 2012
    Posts:
    12,697
    The Draw function should always return a string. Here's the source for CustomFieldType_Number.cs, for example:
    Code (csharp):
    1. using UnityEditor;
    2. using System;
    3.  
    4. namespace PixelCrushers.DialogueSystem
    5. {
    6.  
    7.     [CustomFieldTypeService.Name("Number")]
    8.     public class CustomFieldType_Number : CustomFieldType
    9.     {
    10.         public override FieldType storeFieldAsType
    11.         {
    12.             get
    13.             {
    14.                 return FieldType.Number;
    15.             }
    16.         }
    17.  
    18.         public override string Draw(string currentValue, DialogueDatabase dataBase)
    19.         {
    20.             return EditorGUILayout.FloatField(StringToFloat(currentValue, 0)).ToString();
    21.         }
    22.  
    23.         private float StringToFloat(string s, int defaultValue)
    24.         {
    25.             try
    26.             {
    27.                 return (float)System.Convert.ToDouble(s);
    28.             }
    29.             catch (FormatException)
    30.             {
    31.                 return defaultValue;
    32.             }
    33.         }
    34.  
    35.     }
    36. }
     
  49. TonyLi

    TonyLi

    Joined:
    Apr 10, 2012
    Posts:
    12,697
    Wishlist Sale Ending Soon

    The Asset Store's Wishlist Sale is ending in 1 hour. If you've been waiting to pick up the Dialogue System on sale, time's running out for this opportunity!
     
  50. Duffer123

    Duffer123

    Joined:
    May 24, 2015
    Posts:
    1,216
    Thanks re response above your latest.