Search Unity

Fluent Dialogue

Discussion in 'Assets and Asset Store' started by ReynV, Oct 9, 2018.

  1. ReynV

    ReynV

    Joined:
    Sep 24, 2014
    Posts:
    50
  2. yurifw

    yurifw

    Joined:
    Sep 30, 2018
    Posts:
    2
    Hi, I am trying to create a response chain from an array of strings. Reading the documentation I could create a Response Chain by using the '*' operator (I didn't get why it worked, or why am I multiplying the Yell, but it worked). But this way it only worked when hardcoded, here is what I am trying to do:

    Code (CSharp):
    1.       public override FluentNode Create()    {
    2.         npc = GetComponent<NPC>();
    3.  
    4.         return Yell(npc.sentences);
    5.     }
    6.  
    If I use only the first element from npc.centences ( return Yell(npc.sentences[0]); ) , it works as expected and creates the dialog. The problem is that I do not understand what is going on, and I don't know what those '*' are doing, and therefore I can't create the response chain unless it is hardcoded...
     
  3. ReynV

    ReynV

    Joined:
    Sep 24, 2014
    Posts:
    50
    Hi yurifw!
    Sorry for the late reply.

    I'm not sure what your use case is, the idea is to chain (*) all the sentences together in the FluentScript, like in example 2. Hard coded is by design here.

    I've added the ability to pass an array into Yell, please give me an idea of how you are using it, if it's useful I'll make it part of the next asset store release.

    http://reyn.vlietstra.co.za/wp-content/uploads/Reyn/FluentDialogue_2018_12_15.zip

    Code (CSharp):
    1. public class Conversation2 : MyFluentDialogue
    2. {
    3.     FluentString[] sentences = FluentString.FromStringArray(new string[] { "I love ...", "CAKE!", "And chained responses!" });
    4.  
    5.     public override FluentNode Create()
    6.     {
    7.         return
    8.             Yell(sentences);
    9.     }
    10. }

    Thanks!
     
    peiftronica likes this.
  4. yurifw

    yurifw

    Joined:
    Sep 30, 2018
    Posts:
    2
    I have a few NPCs that just say a few lines when talked to, so I created a script with a public variable of the type string[] with the sentences that npc should speak and a trigger that when fired starts the fluent dialogue. What I wanted was to write the sentences on the unit editor and use the same 2 scripts (fluent dialogue and my dialogue trigger) on all NPC's so I wouldn't have to create one script for each NPC, but just passing an array should be enough, thanks for the answer :)
     
  5. Mounaim7

    Mounaim7

    Joined:
    Apr 14, 2018
    Posts:
    7
    Hello, first thank you so much this helped me a lot since i'm still a beginner, i faced one problem tho, the dialogue is a bit fast, is there a way to display it for x amount of time ?, thank you again.
     
  6. Mounaim7

    Mounaim7

    Joined:
    Apr 14, 2018
    Posts:
    7
    2019.05.12-15.45.png

    I think i figured it out :D
     
  7. ReynV

    ReynV

    Joined:
    Sep 24, 2014
    Posts:
    50
    Hi!
    The other way to pause a specified amount of time is to just pass it as a parameter for Yell(2, ...)
     
  8. Mounaim7

    Mounaim7

    Joined:
    Apr 14, 2018
    Posts:
    7
    Aha right! that went completely over my head, thank you so much!
     
  9. vpinto

    vpinto

    Joined:
    Apr 6, 2013
    Posts:
    21
    Hi, any thoughts about converting your fantastic tool to use TextMeshPro? I haven't taken a deep dive into your code yet, but I have integrated TMP fairly easily with a few other dialogue systems and have had success.
     
  10. ReynV

    ReynV

    Joined:
    Sep 24, 2014
    Posts:
    50
    Hi,
    I'll update it to handle both.

    For yelling you can just change line 85 in YellHandler.cs from
    Code (CSharp):
    1. Text text = YellUI.GetComponentInChildren<Text>();
    To
    Code (CSharp):
    1. TMPro.TextMeshProUGUI text = YellUI.GetComponentInChildren<TMPro.TextMeshProUGUI>();
    Make sure that your yell canvas then contains a TMP UGUI component.

    Making the rest of the system work with TMP is bit more work, I'll do that in the next couple of days.

    Thanks
     
    peiftronica, vpinto and StevenPicard like this.
  11. ReynV

    ReynV

    Joined:
    Sep 24, 2014
    Posts:
    50
  12. vpinto

    vpinto

    Joined:
    Apr 6, 2013
    Posts:
    21
    Thanks! I moved over to your new version, I'm however having some trouble using your write handler script without having any options. I keep getting a "Could not find a Text UI component in the specified Yell UI" however there is a textUI component, and this works without adding in the write handler..

    so I'm either missing something or something is not working as intended. Do I need options to make the Write node work? Can I not use the write node with a YellCanvas?
     
  13. ReynV

    ReynV

    Joined:
    Sep 24, 2014
    Posts:
    50
    Hi.
    Write without options seems to work on my side

    Code (CSharp):
    1. public class Conversation5Test : MyFluentDialogue
    2. {
    3.     public override FluentNode Create()
    4.     {
    5.         return
    6.             Show() *
    7.             Write(0, "<color=#0000ffff>Write</color> writes to a text element").WaitForButton() *
    8.             Hide();
    9.     }
    10. }
    11.  
    "Could not find a Text UI component in the specified Yell UI" is being thrown by the YellHandler, which means you have a Yell that does not have a uGUI text or TextMeshProUGUI somewhere in it's children.

    Post your FluentScript for me to diagnose some more.

    Thanks
     
  14. vpinto

    vpinto

    Joined:
    Apr 6, 2013
    Posts:
    21
    Firstly, thank you for the help.

    I have been just editing your example scripts, and my process has been as follows, maybe you can decipher what i'm doing wrong or missing

    - add writeHandler to Talk level game object
    - slot the gameobject with the text component into writeHandler
    - change the example script to Write instead of Yell
    - Set DialogueUI and OptionItemUI to Talk ( I know this is probably where I'm going wrong)

    the problem I have is that without setting the public game objects of Options Presenter, it will not show the YellCanvas object that is hidden, where it is in fact typing out the text into the text object, it just remains hidden. I'm not entirely sure what Show() is showing, but unless I activate the gameobject with the canvas(YellCanvas), I cannot get the object to show, even though the text is there. When I activate the YellCanvas object manually, it works, but then when I go back to try it a second time, it skips over the Write node, and goes straight to the Yellnode.

    Here is the edited example code
    Code (CSharp):
    1. using Fluent;
    2.  
    3. /// <summary>
    4. /// There are two things explained in this example.
    5. /// The first is that we now inherit from MyConversation which contains the code to stop the player from moving
    6. /// The second is that concept of chaining responses, they will each be executed from Start() to End()
    7. /// </summary>
    8. public class Conversation2 : MyFluentDialogue
    9. {
    10.     FluentString[] sentences = FluentString.FromStringArray(new string[] { "I love ...", "CAKE!", "And chained responses!" });
    11.  
    12.     public override FluentNode Create()
    13.     {
    14.         return
    15.             Show() *
    16.             Write("I am writing to a text box wooo") *
    17.             Yell(sentences) *
    18.             Hide();
    19.     }
    20. }
    hopefully this is making sense, thanks again for the help
     
  15. ReynV

    ReynV

    Joined:
    Sep 24, 2014
    Posts:
    50
    Ok, that works on my side.

    Here is a screenshot of my setup.
    Do you have a YellCanvas as a child of talk ?

    Show() shows the OptionsPresenter, which Write() writes to.
    I've added some comments which I'll update on the next release.

    If that is still not working lets have a quick skype call: reyn.vlietstra

    upload_2019-6-20_21-51-18.png
     
  16. ReynV

    ReynV

    Joined:
    Sep 24, 2014
    Posts:
    50
    I changed the options presenter to not complain that there is no options panel or options item UI defined.
    Didn't think people would use it that way, but it makes sense. (not sure if that was your problem)
     

    Attached Files:

  17. ReynV

    ReynV

    Joined:
    Sep 24, 2014
    Posts:
    50
    What are you trying to do ?
    Your results looks like this:

    upload_2019-6-20_22-45-9.png
    Are you trying to write the sentences to a dialog or a yell canvas ?
     
    Last edited: Jun 27, 2019
  18. sunmoonstarsrain

    sunmoonstarsrain

    Joined:
    Apr 30, 2019
    Posts:
    5
    Hi! Thank you for sharing your asset for free. I want to use it for my project but I'm confused about a couple of things.
    It looks like there is an Editor but I can't figure out how to access it.
    Also, I want to use this for a project where there is no "player", but rather you are watching a paper doll style character who faces you and his dialogue appears in a text box with his name below him. So there's no moving around, everything is stationary. I am having trouble getting started and would appreciate any help. Thanks! :)
     
  19. ReynV

    ReynV

    Joined:
    Sep 24, 2014
    Posts:
    50
    Hi.
    Mhm, what makes you say there is an editor ? If you are referring to the tree inside the conversation component then that is built-up from the code in the FluentScript itself.

    Fluent dialogue has some components you have to setup in unity but after that everything happens in scripts.
    Please have a look at the tutorials at http://reyn.vlietstra.co.za/?page_id=248

    You can start a conversation by calling Run() on a FluentScript, you don't need to use the FluentManager in the examples which assumes there is a character running around.

    Let me know if you want me to build you an example.

    Thanks
     
  20. sunmoonstarsrain

    sunmoonstarsrain

    Joined:
    Apr 30, 2019
    Posts:
    5
    Thank you for your quick reply! I saw the Editor folder and up in the Component tab there is a Fluent menu so I thought maybe there was an editor I was missing out on. I read the tutorials and played around with it a little, i am sure I can build on what the tutorials show but I'm still learning about programming. I tried to call Run() but it wasn't correct. If you could please give me a simple example it would be great! My goal for this project is to make something where either the dialogue starts automatically (upon entering the Unity Scene) or the player taps the screen and the dialogue starts. The player will have to tap to move the dialogue along.
    Thank you!
     
  21. ReynV

    ReynV

    Joined:
    Sep 24, 2014
    Posts:
    50
    I think this might be a rough place to start to learn some of the basics, but lets give it a go.
    The code below runs when you click on a specified button, the button is also disabled until the conversation finishes.

    The attached zip has the example scene for you to test out.

    Code (CSharp):
    1.  
    2. public class Conversation17 : MyFluentDialogue
    3. {
    4.     public Button StartButton;
    5.  
    6.     public void Start()
    7.     {
    8.         StartButton.onClick.AddListener(() =>
    9.         {
    10.             StartButton.interactable = false;
    11.             Run();
    12.         });
    13.     }
    14.  
    15.     public override void OnFinish()
    16.     {
    17.         base.OnFinish();
    18.         StartButton.interactable = true;
    19.     }
    20.  
    21.     public override FluentNode Create()
    22.     {
    23.         return
    24.         Show() *
    25.         Write("You just initiated a converation with a button!").WaitForButton() *
    26.         Write("Let me ask you a question").WaitForButton() *
    27.         Write("Pick one") *
    28.         Options
    29.         (
    30.             Option("1!") *
    31.                 Write("Correct!").WaitForButton() *
    32.                 Write("Bye") *
    33.                 End() *
    34.             Option("2!") *
    35.                 Write("I said one!").WaitForButton()
    36.         );
    37.     }
    38. }
    39.  
     

    Attached Files:

    Last edited: Jun 29, 2019
  22. sunmoonstarsrain

    sunmoonstarsrain

    Joined:
    Apr 30, 2019
    Posts:
    5
    Thank you so much!! I tried the example you gave and I think it might be perfect. I'll try it in my project this weekend and let you know how it is working out for me.
     
  23. sunmoonstarsrain

    sunmoonstarsrain

    Joined:
    Apr 30, 2019
    Posts:
    5
    Thanks again, it's working out fine so far. I put it in the project as it was in the example and got it to work. The only problem I have is that for some reason, I can't get the options to change text size. It looks fine in the editor, but when I run the game, the text for the options is always super tiny. I uploaded a couple of pics to show what I mean.
     

    Attached Files:

  24. vpinto

    vpinto

    Joined:
    Apr 6, 2013
    Posts:
    21
    Sorry for taking so long to respond, thank you again for all of your help.

    What I'm trying to do is use the write handler to get a typrwriter effect between multiple, separate ui objects.

    As such I was trying to use a YellCanvas in order to Write instead of Yell, but it seems like there can only be one ui element using Write at a time, because it has no way of distinguishing between which ui gameobject to use the write command to multiple ui gameobjects.

    let me know if I'm thinking about this wrong. I just want to have a conversation between two game objects, both using the typewriter effect from the write node.

    thanks again,
     
  25. wolfulus

    wolfulus

    Joined:
    Jun 10, 2015
    Posts:
    12
    is there any way to continue writing text after Options() or make sequential questions on the same conversation script?
     
  26. ReynV

    ReynV

    Joined:
    Sep 24, 2014
    Posts:
    50
    Damn sorry, for some reason I stopped getting email notifications from this thread.

    @sunmoonstarsrain I don't know why your text sizes are different between a build and the editor ... It seems to work in both a WebGL and Windows build for me. Have you solved the issue ? Maybe try the new 2019.3 beta version of unity, it has high dpi support for the editor.

    @vpinto Have a look at example 5 (write), which lets you specify a specific UI element to write to. Does that fulfill your requirement ?

    @wolfulus I'm trying to wrap my head around your use case. To me dialogue is a tree which you step further into, you can also go back a branch... Ok, I understand what you'd like to do, it turns into something like a questions/answer/test flow. Let me think about how I'm going to implement this.

    Thanks!
     
    peiftronica likes this.
  27. ReynV

    ReynV

    Joined:
    Sep 24, 2014
    Posts:
    50
    @wolfulus In this conversations two questions are asked sequentially and the number of correct answers is yelled at the end. Is that what you had in mind ?

    Code (CSharp):
    1.  
    2. public class SomeConversation : MyFluentDialogue
    3. {
    4.     private int numCorrect = 0;
    5.     public override FluentNode Create()
    6.     {
    7.         return
    8.             Do(() => numCorrect = 0) *
    9.  
    10.             Show() *
    11.             Write(0, "What is 1 + 1") *
    12.             Options
    13.             (
    14.                 Option("2") *
    15.                     Hide() *
    16.                     Yell("Correct") *
    17.                     Do(() => numCorrect += 1) *
    18.                     End() *
    19.                 Option("3") *
    20.                     Hide() *
    21.                     Yell("...") *
    22.                     End()
    23.              ) *
    24.  
    25.             Show() *
    26.             Write(0, "What is 2 + 5") *
    27.             Options
    28.             (
    29.                 Option("4") *
    30.                     Hide() *
    31.                     Yell("Ouch") *
    32.                     End() *
    33.                 Option("7") *
    34.                     Hide() *
    35.                     Yell("Correct") *
    36.                     Do(() => numCorrect += 1) *
    37.                     End()
    38.              ) *
    39.              Yell(Eval(() => "You have " + numCorrect + " correct"));
    40.     }
    41. }
    42.  
    You can make that neater like this: (note to get the following working I had to make some changes, here is the new version. It'll be in the next asset store update as well.)
    Code (CSharp):
    1.  
    2. public class Conversation5b : MyFluentDialogue
    3. {
    4.     private int numCorrect = 0;
    5.  
    6.     FluentNode CreateAddQuestion(int a, int b)
    7.     {
    8.         FluentNode correctOption =
    9.             Option((a + b).ToString()) *
    10.                 Hide() *
    11.                 Yell("Correct!") *
    12.                 Do(() => numCorrect += 1) *
    13.                 End();
    14.  
    15.         FluentNode incorrectOption =
    16.             Option((a + b + UnityEngine.Random.Range(1, 2)).ToString()) *
    17.                 Hide() *
    18.                 Yell("Incorrect") *
    19.                 End();
    20.  
    21.         // Randomly swap answers so that the first answer isn't always the correct answer
    22.         bool swap = UnityEngine.Random.value > 0.5f;
    23.  
    24.         return
    25.             Show() *
    26.             Write(0, $"What is {a} + {b} ?") *
    27.             Options
    28.             (
    29.                 swap ? incorrectOption * correctOption : correctOption * incorrectOption
    30.             );
    31.     }
    32.     public override FluentNode Create()
    33.     {
    34.         return
    35.             Do(() => numCorrect = 0) *
    36.             CreateAddQuestion(1, 1) *
    37.             CreateAddQuestion(3, 5) *
    38.             Yell(Eval(() => "You have " + numCorrect + " correct"));
    39.     }
    40. }
    41.  
     
    Last edited: Oct 6, 2019
  28. matteo-piccioni

    matteo-piccioni

    Joined:
    Jul 4, 2014
    Posts:
    49
    Hello,
    my game is 2D and my character use BoxCollider2D, can I use FluentDialog?
    I see that in your DEMO I should add a 3D Proximity Trigger to a 'Talk object'
    Thanks
     
  29. ReynV

    ReynV

    Joined:
    Sep 24, 2014
    Posts:
    50
    Hi Matteo!

    The FluentManger class was just an example. You can use whatever mechanism you want to determine if the player is in a position to start a FluentScript and then just call Run() on it.

    Look at this example:

    Code (CSharp):
    1. /// <summary>
    2. /// This example shows how to start a conversation with a button
    3. /// </summary>
    4. public class Conversation9b : MyFluentDialogue
    5. {
    6.     public Button StartButton;
    7.  
    8.     public void Start()
    9.     {
    10.         StartButton.onClick.AddListener(() =>
    11.         {
    12.             StartButton.interactable = false;
    13.             Run();
    14.         });
    15.     }
    16.  
    17.     public override void OnFinish()
    18.     {
    19.         base.OnFinish();
    20.         StartButton.interactable = true;
    21.     }
    22.  
    23.     public override FluentNode Create()
    24.     {
    25.         return
    26.             Yell("You just initiated a converation with a button!");
    27.     }
    28. }
    29.  
    This doesn't use the FluentManager or any collisions to work. You'd obviously have the button defined outside the conversation, this was just to keep the code for the example together.

    My suggestion would be
    1. Detect if your player is close to where he can initiate a dialogue.
    2. Store the detected FluentScript somewhere
    3. Indicate to the user that he can initiate a conversation
    4. When he presses a button call Run() on the stored FluentScript

    Let me know if you don't get it to work.
    Thanks
     
  30. matteo-piccioni

    matteo-piccioni

    Joined:
    Jul 4, 2014
    Posts:
    49
    Yes, thank you very much!
    I did the magic with Run() command :D
     
    ReynV likes this.
  31. SomewhatEvil_

    SomewhatEvil_

    Joined:
    Apr 1, 2019
    Posts:
    2
    Hi,
    I'm using booleans in another script to change what happens within dialogue, yet when I initiate dialogue the boolean is instantly set to true. Why is this? And is there a way I can stop this from happening?

    Here's the code in question:
    Code (CSharp):
    1. public class OptionscriptBOOLTEST : MyFluentDialogue
    2. {
    3.     //THIS GRABS THE BOOLHOLDER
    4.     public BoolHolder boolholder;
    5.  
    6.     public override void OnStart()
    7.     {
    8.  
    9.         //THIS CHECKS THE BOOLS
    10.         GameObject stuffholder = GameObject.Find("StuffHolder");
    11.         boolholder = stuffholder.GetComponent<BoolHolder>();
    12.  
    13.     }
    14.  
    15.     public override void OnFinish()
    16.     {
    17.  
    18.     }
    19.  
    20.     public override FluentNode Create()
    21.     {
    22.         return
    23.             If(() => boolholder.CubeYeet_test = false,
    24.                 Show() *
    25.                     Write(0, "Hey! You! Go over to that cube and interact with it!") *
    26.                     Options
    27.                     (
    28.                         Option("Ok.") *
    29.                                             End()
    30.                     ) *
    31.  
    32.             If(() => boolholder.CubeYeet_test = true,
    33.               Show() *
    34.                 Write(0, "Is it done?") *
    35.  
    36.                 Options
    37.                 (
    38.                     Option("Yes") *
    39.                         Write(0, "Good, finally!") *
    40.                         Options
    41.                             (
    42.                            Option("O- Okay?") *
    43.                                   End()
    44.                             )
    45.                 )
    46.         ));
    47.  
    48.     }
    49. }
     
  32. ReynV

    ReynV

    Joined:
    Sep 24, 2014
    Posts:
    50
    Hi @BMoblivio!
    It seems your If() is setting a value instead of testing.
    Try
    Code (CSharp):
    1. If(() => boolholder.CubeYeet_test == false, ...)
    or
    Code (CSharp):
    1. If(() => !boolholder.CubeYeet_test, ...)
     
  33. SomewhatEvil_

    SomewhatEvil_

    Joined:
    Apr 1, 2019
    Posts:
    2
    Argh, this whole time?! I had no idea it would be that simple, this whole time I thought I was just checking the value at the start of dialogue. Thank you very, very much for the quick response, this will help me a lot.
     
  34. SuperPoopsy

    SuperPoopsy

    Joined:
    Jan 20, 2020
    Posts:
    17
    Hello, i have a possibly trivial question, but unfortunately my experience in C# is very limited and i'm struggling to find a clear answer. I'm calling run() on a fluent script from a different component, which manages the collision with interactable items in my game and makes visual prompts appear/disappear, among other things. I would like the component to know when the dialogue has been completed, so that it can execute a different function (in this case, reset everything back so that you can interact again).

    My (possibly S***ty) solution, was to have my component read a bool variable i have set in the fluentscript, whose value gets changed at onfinish(). While this seem to work to avoid starting run() more than once (i just check if that variable is false as a condition), the rest of the component doesn't know when to trigger the 'reset' function.
    I understand i should probably manage this using the onfinish() callback you implemented, but unfortunately i don't understand how delegates work.

    Is it possible for you to write a generic example of how to properly manage a similar situation?
    Thank you.
     
  35. ReynV

    ReynV

    Joined:
    Sep 24, 2014
    Posts:
    50
    Hi @SuperTopen, I might be misunderstanding, does your question boil down to "I want to call a method on a different component" ? There are numerous ways to do that, easiest is to expose the component you want to reset by either adding it as a public variable to your script and dragging that into the slot in the editor or using GameObject.Find*() to find the object you want to reset in your script's OnStart() method and calling reset OnFinish.
     
  36. SuperPoopsy

    SuperPoopsy

    Joined:
    Jan 20, 2020
    Posts:
    17
    Hello @ReynV To be honest, i guess what i was really looking for is a practical implementation of delegates so i can learn how they work :D
     
  37. ReynV

    ReynV

    Joined:
    Sep 24, 2014
    Posts:
    50
    @SuperTopen, ok, there are lots of resources for that. Another way is to not call Run() on the FluentScript from your managing object but to call a new method that takes an Action, stores the action and calls it OnFinish.

    Something like this.
    Code (CSharp):
    1.         Action callback;
    2.         void RunAndCallback(Action a)
    3.         {
    4.             callback = a;
    5.             Run();
    6.         }
    7.  
    8.         void OnFinish()
    9.         {
    10.             callback();
    11.         }
    I'd like to stay away from implementing that on my side, there are so many ways of doing things that I'd like to keep it open ended.
     
  38. SuperPoopsy

    SuperPoopsy

    Joined:
    Jan 20, 2020
    Posts:
    17
    Indeed there are resources but I've started studying C# a week ago and i think i'm still missing so many steps. i tend to learn more quickly by implementing new stuff in 'practical' scenarios.

    Thank you, that is really helpful!
     
  39. Miguelfanclub

    Miguelfanclub

    Joined:
    Jun 14, 2015
    Posts:
    64
    Downloaded, then imported then error:
    Assets/FluentDialogue/Example/Conversation13.cs(8,30): error CS0118: 'Language' is a namespace but is used like a type

    in 2019.3
     
  40. ReynV

    ReynV

    Joined:
    Sep 24, 2014
    Posts:
    50
    Hi @Miguelfanclub !

    Sorry for the late reply, I don't know why I'm not getting notification emails.
    "Language" is a type in Fluent Dialogue. It seems you have a namespace "Language" somewhere in your code.

    I think I need to rename it to something less generic.

    Simplest would be to just rename it yourself.
     
  41. bugscuffle

    bugscuffle

    Joined:
    Dec 8, 2015
    Posts:
    73
    I am working with a Event Manager Asset called uSignal. Can it fire the Fluent scripts if they are attached to a listener object?
     
  42. ReynV

    ReynV

    Joined:
    Sep 24, 2014
    Posts:
    50
    Hi!

    Can uSignal call methods ?
    Call the Run() method on the FluentScript.

    Thanks
     
    bugscuffle likes this.
  43. Giantsmall

    Giantsmall

    Joined:
    Apr 28, 2019
    Posts:
    18
    Hello, I have problems with hovering/picking any of displayed options on my scene - what might be the cause?

    UPDATE: Found it - i was simply missing graphic raycaster on the dialog.
     
    Last edited: Apr 9, 2020
    ReynV likes this.
  44. avillaindesire

    avillaindesire

    Joined:
    Mar 30, 2020
    Posts:
    4
    Hi ReynV! Thanks for sharing this with the community! I'm new to C# & Unity, but I was able to get it working for my project. One thing that gave me some trouble was the ProximityInitiator script. Since I had a mesh collider on my ground plane, AddScript() was returning true for every instance. I changed OnTriggerEnter(Collider collider) to OnTriggerEnter(Collider other) and checked to see if other was the player. I just wanted to mention that in case anyone else is running into the problem of RecalculateUIActionText() always saying "Talk". Thanks again!
     
    ReynV likes this.
  45. ReynV

    ReynV

    Joined:
    Sep 24, 2014
    Posts:
    50
    @avillaindesire Yes, there are some things I can do it make it more generic, I'll get to that at some points, thanks!
     
  46. avillaindesire

    avillaindesire

    Joined:
    Mar 30, 2020
    Posts:
    4
    Hello. I'm trying to add a close button to the Options Presenter Dialog and I'm getting an error when I click it. I'm trying to call the End() function in the Objects Presenter script:
    closeButton.onClick.AddListener(delegate { optionsPresenterScript.End(); });
    That code is in my MyFluentDialogue attached to my NPC. When I click the button and it runs the code, it comes back with a null reference error:

    NullReferenceException: Object reference not set to an instance of an object
    Fluent.OptionsPresenter.End () (at Assets/FluentDialogue/Base/OptionsPresenter.cs:107)

    Is there a better way to do this? Any help would be appreciated!
     
  47. ReynV

    ReynV

    Joined:
    Sep 24, 2014
    Posts:
    50
    @avillaindesire
    My requirements were to drive the opening and closing of the dialog through the fluent script, I get why you'd want to be able to do that through a button though.

    I had a quick look. For now, I believe you can safely just hide/close the dialog yourself if you are not expecting something else to happen after closure (like a yell).

    I'll try and get to this in the next 48 hours.

    Thanks
     
  48. ReynV

    ReynV

    Joined:
    Sep 24, 2014
    Posts:
    50
    @avillaindesire Sorry, that affects too many things for the amount of time I have right now.
    I've adding global script interruption to my todo list.
    Thanks!
     
  49. avillaindesire

    avillaindesire

    Joined:
    Mar 30, 2020
    Posts:
    4
    Not a problem, @ReynV!! Thank you so much for looking into it and for all the work you put into this project! It's been fun working with it.
     
  50. avillaindesire

    avillaindesire

    Joined:
    Mar 30, 2020
    Posts:
    4
    Hey @ReynV,
    I was able to do it with three calls. I had to make ActionCompleted() public, though. Not sure if this will help you as you try to implement it properly, but it works for me.

    optionsPresenterScript.ClearOptions();
    FluentManager.Instance.ActionCompleted(GetComponent<FluentScript>());
    optionsPresenterScript.Hide();
     
    Last edited: May 9, 2020