// Add to top of the scriptusingSystem;usingConversa.Runtime.Events;
Initial Updates to DiaTrigger.cs
// Add to top of the scriptusingConversa.Runtime;usingConversa.Runtime.Events;usingConversa.Runtime.Interfaces;...//Inside Class[SerializeField] privateConversation conversation;privateConversationRunner runner;...//Setting things upprivatevoidStart(){ runner =newConversationRunner(conversation);runner.OnConversationEvent.AddListener(HandleConversationEvent);}
Buckle up, Time for Delegates!
In javascript, you can pass a function as a variable. Not in C#. Now, you have to create a delegate. This video, up to 3:28 will explain the shenanigans. If you go past that, you will get confused.
Just the additional Script added for DiaManager.
//Adding Namespaces requiredusingSystem;...//Storing the function from the conversation starter script into this onepublicdelegatevoidNextMessageDelegate();privateNextMessageDelegate NextMessageFunction;//Initializing itprivatevoidStart(){... NextMessageFunction = NextMessage;}privatevoidNextMessage(){Debug.Log("Testing out this new thing, yo.");}//Having it as a separate function so you can drag and drop it into the PlayerInputComponent//if the PlayerInputComponent is set to "Invoke Unity Events"publicvoidAdvance(InputAction.CallbackContext ctx){if (ctx.performed) {NextMessageFunction(); }}//In the Show Message option that opens up the Dialogue boxpublicvoidShow(string actor,string message,Sprite avatar,Action onContinue){... NextMessageFunction = () =>onContinue();}
Here are some failures I got when trying to set "onContinue" to a function in the DiaManager: