Custom script execution

Announcements, support questions, and discussion for the Dialogue System.
Post Reply
angelothic
Posts: 6
Joined: Sun Oct 29, 2023 5:05 pm

Custom script execution

Post by angelothic »

Hello,

I'm using dialogue system for tutorials.
For example I have 5 dialog on 5 step. On 3nd step I want show hand icon on button.
When dialog reach step 5. iwant execute specific script from gameobject component.


Thank you.
User avatar
Tony Li
Posts: 21679
Joined: Thu Jul 18, 2013 1:27 pm

Re: Custom script execution

Post by Tony Li »

Hi,

There are 3 ways to accomplish custom script execution:

1. Cutscene Sequences. Use a sequencer command. You can use the built-in commands (reference) or write a custom command. For example, if your hand icon GameObject is named "Hand Icon" and you want to activate it in the 3rd dialogue entry node, set the 3rd dialogue entry node's Sequence to:

Code: Select all

{{default}}; SetActive(Hand Icon)
2. Or use Lua Functions. You can register your own C# methods with Lua. Then use it in the dialogue entry node's Sequence field.

3. Or connect your script method to the dialogue entry node's OnExecute() UnityEvent.
angelothic
Posts: 6
Joined: Sun Oct 29, 2023 5:05 pm

Re: Custom script execution

Post by angelothic »

Another question about it :)

Can you give me example of call custom script method ?
For example;
customComponent.customMethod("https://www.google.com")

Thank you very much.
User avatar
Tony Li
Posts: 21679
Joined: Thu Jul 18, 2013 1:27 pm

Re: Custom script execution

Post by Tony Li »

There are many ways to do it. The two simplest ways, without having to write any code are:

1. Use the SendMessage() sequencer command. Assuming customMethod() is on a GameObject named "My GameObject", set the dialogue entry's Sequence field to:

Code: Select all

SendMessage(customMethod, http://www.google.com, My GameObject)

2. Or connect to the method using an OnExecute() scene event.
Post Reply