- Home /
How to make the scene fully initalized like the first scene when you first open the game when switching scenes?
Hi all,
I meet a problem, could anyone give me some help?
Just assume I have three scenes, Level 0 MenuPage (without Manomotion SDK) Level 1 Game1 (with Manomotion SDK) Level 2 Game2 (with Manomotion SDK)
Manomotion is a SDK that can detect gestures and add some interaction.
When I build and run all of them together, I find that from level 0 to level 1, the SDK works very good, but after Level 1 finish (I have a timer for the 30s) and it auto jump to Level 2, the SDK stop work, the FPS and processing time become ----.
Then I try to build Level 1 and Level 2 separately, and it works fine. When I build them together, it does not work. And I use almost the same code and same Licence in Level 1 and Level 2.
I have tried many ways like reloading the scene, unloading resources, and even loading an empty scene before going to the SDK scene but it did not work.
[RuntimeInitializeOnLoadMethod(RuntimeInitializeLoadType.BeforeSceneLoad)]
static void OnGameLoaded()
{
foreach (GameObject go in GameObject.FindObjectsOfType<GameObject>())
go.SetActive(false);
SceneManager.LoadScene(0);
}
public static void ClearCache()
{
if (Caching.ClearCache())
{
Debug.Log("Successfully cleaned the cache");
}
else
{
Debug.Log("Cache is being used");
}
}
IEnumerator ExampleCoroutine()
{
yield return new WaitForSeconds(3);
OnGameLoaded();
SceneManager.LoadScene(sceneName: "EmptyScene");
ClearCache();
SceneManager.LoadScene(sceneName: "Scene2");
}
This problem struck me a few weeks, and I still didn't find a solution. Could you please help me with that? Many thanks.
Your answer
Follow this Question
Related Questions
UnloadSceneAsync() does not seem to work with additive scenes. 1 Answer
Scene loading delay after upgrade 4.6 to 5. 0 Answers
Old scene still appears for short time when switching scene 0 Answers
Will DontdestroyonLoad() Keep Child Objects too 2 Answers
How can I avoid a framerate drop when asynchronously loading scenes 0 Answers