Page 1 of 1

Custom script execution

Posted: Tue Oct 31, 2023 5:58 pm
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.

Re: Custom script execution

Posted: Tue Oct 31, 2023 7:46 pm
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.

Re: Custom script execution

Posted: Wed Nov 15, 2023 12:00 pm
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.

Re: Custom script execution

Posted: Wed Nov 15, 2023 12:11 pm
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.