Page 1 of 1

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

Posted: Fri Nov 12, 2021 5:01 am
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!

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

Posted: Fri Nov 12, 2021 8:57 am
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();
    }
}