Page 1 of 1

Calling a script that calls other scripts from other classes at the end of a conversation

Posted: Sun May 12, 2024 2:12 pm
by Zoraph
Hi, I am trying to call a c# script that I put directly on the NPC itself to change scene. But it needs to call a scene loader not on this scene but loaded in it using scene load additive. I followed your video on Lua and how to connect scripts, but I am not sure what to do when scripts needs to call other scripts.

Code: Select all

    public void LoadPEPScene()
    {
        LoaderGameManager.Instance.LoadSpecificPEPScene(19);
    }

    [Tooltip("Typically leave unticked so temporary Dialogue Managers don't unregister your functions.")]
    public bool unregisterOnDisable = false;

    void OnEnable()
    {
        Lua.RegisterFunction(nameof(LoadPEPScene), this, SymbolExtensions.GetMethodInfo(() => LoadPEPScene()));
    }

    void OnDisable()
    {
        if (unregisterOnDisable)
        {
            Lua.UnregisterFunction(nameof(LoadPEPScene));
        }
    }
This is what the LoadPEPScene() is calling

Code: Select all

    public void LoadSpecificPEPScene(int sceneLoadIndex)
    {
        backgroundImage.sprite = backgrounds[Random.Range(0, backgrounds.Length)];
        loadingScreen.SetActive(true);

        StartCoroutine(WaitTime());
        StartCoroutine(GenerateTip());

        sceneLoading.Add(SceneManager.UnloadSceneAsync((int)SceneIndexes.TownOfBeginning));
        sceneLoading.Add(SceneManager.UnloadSceneAsync((int)SceneIndexes.InventorySystemUI));
        sceneLoading.Add(SceneManager.LoadSceneAsync(sceneLoadIndex, LoadSceneMode.Additive));

        StartCoroutine(GetSceneLoadProgress());
    }
In short, a method that calls another class' method and that method also calls multiple Coroutine. I thought I might just need to call the method from c# that init the process, but it is giving me an error at that line:

LoaderGameManager.Instance.LoadSpecificPEPScene(19);

How should I proceed with this for this to work?

Re: Calling a script that calls other scripts from other classes at the end of a conversation

Posted: Sun May 12, 2024 2:30 pm
by Zoraph
I solved it lol. I have another issue thought, The dialogue system do not close and will follow me to the other scene and the conversation will remain at the last node since I did not press on the continue button. Even by creating a child node that is empty with only the script call, the previous node is still visible when I enter the next scene. How can I resolve this?

Re: Calling a script that calls other scripts from other classes at the end of a conversation

Posted: Sun May 12, 2024 4:27 pm
by Tony Li
Hi,

You can make your conversation end (e.g., include the Continue() sequencer command in the last node) or you can manually stop it in script using the C# method DialogueManager.StopConversation().

Re: Calling a script that calls other scripts from other classes at the end of a conversation

Posted: Mon May 13, 2024 12:44 am
by Zoraph
yep worked. Thanks :)

Re: Calling a script that calls other scripts from other classes at the end of a conversation

Posted: Mon May 13, 2024 9:45 am
by Tony Li
Glad to help!