How to refer to the Script of the resource path in the Custom Sequence Command?

Announcements, support questions, and discussion for the Dialogue System.
Post Reply
2gold
Posts: 19
Joined: Wed Aug 18, 2021 2:56 am

How to refer to the Script of the resource path in the Custom Sequence Command?

Post by 2gold »

Hello Tony, I faced a problem again while using this asset. :shock:

This is the structure of the game.
When the [DAY END] button is activated in the UI, you can press this button to move to the next day. However, the conditions under which this button is activated are not constant, I tried to create and use the Custom Sequence command called DayEndOn().
The command worked by default, but the problem is that the function in the external script that controls the [DAY END] button cannot be executed.

Is there a way to call a function of an external script(in Resource) in the Custom Sequence command? (That is instance script, but it didn't work.) Or if you have any reference, please let me know!

If I have to go on a huge journey, I have to think of a simpler way!
User avatar
Tony Li
Posts: 21977
Joined: Thu Jul 18, 2013 1:27 pm

Re: How to refer to the Script of the resource path in the Custom Sequence Command?

Post by Tony Li »

Hi,

Is the [DAY END] button part of the conversation?

If you have written a custom sequencer command DayEndOn() in a script named SequencerCommandDayEndOn.cs, then your script can do anything you can normally do in C#. For example:

Code: Select all

public class SequencerCommandDayEndOn : SequencerCommand
{
    void Awake()
    {
        var myExternalScript = FindObjectOfType<MyExternalScript>(); // Find instance of MyExternalScript in scene.
        if (myExternalScript == null) Debug.LogError("DayEndOn error: No MyExternalScript in scene.");
        else myExternalScript.SomeFunction();
    }
}
Post Reply