Calling a script that calls other scripts from other classes at the end of a conversation
Posted: Sun May 12, 2024 2:12 pm
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.
This is what the LoadPEPScene() is calling
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?
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));
}
}
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());
}
LoaderGameManager.Instance.LoadSpecificPEPScene(19);
How should I proceed with this for this to work?