Calling a custom unity function after the end of a dialogue
Re: Calling a custom unity function after the end of a dialogue
Glad to help! Thanks for your patience and for not reaching through the Internet tubes to strangle me for my habit of replying with great walls of text.
-
- Posts: 73
- Joined: Tue Jul 25, 2023 1:34 am
Re: Calling a custom unity function after the end of a dialogue
Okay, so new question sir.
How do I invoke code at the end of certain dialogue. I know that this one was about conversation end or start, but sequencer command works for this?
I'm thinking that I could invoke a dialogue that asks if the player wants to move to a location after clicking on the trigger and when they hit no, it doesn't do anything. When they hit yes, they move to another scene or at least they invoke code that plays animation and moves them to another scene.
How do I invoke code at the end of certain dialogue. I know that this one was about conversation end or start, but sequencer command works for this?
I'm thinking that I could invoke a dialogue that asks if the player wants to move to a location after clicking on the trigger and when they hit no, it doesn't do anything. When they hit yes, they move to another scene or at least they invoke code that plays animation and moves them to another scene.
Re: Calling a custom unity function after the end of a dialogue
Hi,
If it's okay to run that function while the conversation is technically still active but at the end, add an empty node to the end. Put your commands in the Script, Sequence, and/or OnExecute() Event sections. If you use the Sequence field, put "required" in front of your commands, and also include "Continue()" such as:
If it's okay to run that function while the conversation is technically still active but at the end, add an empty node to the end. Put your commands in the Script, Sequence, and/or OnExecute() Event sections. If you use the Sequence field, put "required" in front of your commands, and also include "Continue()" such as:
Code: Select all
required LoadLevel(Next Scene);
Continue()
-
- Posts: 73
- Joined: Tue Jul 25, 2023 1:34 am
Re: Calling a custom unity function after the end of a dialogue
Im not sure if i follow. I understand the empty node part but everything else seems a bit above what i understand.
To be honest the scene to scene transition code itself is a bit beyond me so i only really know how to do it one way. What does your thing suggest?
To be honest the scene to scene transition code itself is a bit beyond me so i only really know how to do it one way. What does your thing suggest?
-
- Posts: 73
- Joined: Tue Jul 25, 2023 1:34 am
Re: Calling a custom unity function after the end of a dialogue
Hi tony,Im still having questions about this. I already have a script but i still dont know how to call it with a dialogue sequencer. I dont want to use the dialogue sequencer to activate the scene change, i want the script to do it, which you might have been confused by.
Is there anyway c# code can be called with a sequencer or a dialogue system trigger option im not aware of?
Is there anyway c# code can be called with a sequencer or a dialogue system trigger option im not aware of?
Re: Calling a custom unity function after the end of a dialogue
Yes. If your C# code is in method in a script, and that script is on a uniquely-named GameObject, you can use the SendMessage() sequencer command. For example, say your script is named MyAwesomeSceneChanger, and it has a method named ChangeScene("sceneName"), like this:simplepleasuresdxy wrote: ↑Thu Aug 10, 2023 12:08 pmIs there anyway c# code can be called with a sequencer or a dialogue system trigger option im not aware of?
Code: Select all
public class MyAwesomeSceneChanger : MonoBehaviour
{
public void ChangeScene(string sceneName)
{
SceneManager.LoadScene(sceneName);
}
}
Code: Select all
SendMessage(ChangeScene, Moon Lake, MySceneChanger)
Code: Select all
required SendMessage(ChangeScene, Moon Lake, MySceneChanger);
Continue()
Code: Select all
using UnityEngine;
namespace PixelCrushers.DialogueSystem.SequencerCommands
{
public class SequencerCommandChangeScene : SequencerCommand
{
var sceneChanger = GameObject.FindFirstObjectByType<MyAwesomeSceneChanger>();
if (sceneChanger == null) Debug.LogError("Can't find MyAwesomeSceneChanger");
else sceneChanger.ChangeScene(GetParameter(0));
Stop();
}
}
Code: Select all
required ChangeScene(Moon Lake;
Continue()
-
- Posts: 73
- Joined: Tue Jul 25, 2023 1:34 am
Re: Calling a custom unity function after the end of a dialogue
Okay. I see. Can the send message sequence change a c# boolean from false to true or would i have to make a script to change things? I have a boolean in a data container from scene to scene and i could create a script that when activated, turns that boolean to true, but now im wondering of send message can directly affect the boolean.
Re: Calling a custom unity function after the end of a dialogue
No, the SendMessage can pass a string parameter or no parameter, but that's it. Here's an example of passing a string parameter:
Here's an example of no parameter:
Code: Select all
SendMessage(ChangeScene, Moon Lake, MySceneChanger);
Code: Select all
SendMessage(OpenDoor, , Front Door)