fuzigiwa2
@fuzigiwa2 (義将 藤極)

Are you sure you want to delete the question?

If your question is resolved, you may close it.

Leaving a resolved question undeleted may help others!

We hope you find it useful!

SceneManager.LoadSceneAsync()の読み込み速度の向上を行いたい

Unity2020.3.1で開発を行っております。

private void sceneManagerLoad()
{
    sceneManagerLoadAsync();
    sceneManagerLoadAsyncFast();
}

private void sceneManagerLoadAsync()
{
    loadSceneAsyncFlag = false;
    StartCoroutine( loadSceneAsync( "logo" ) );
}

private void sceneManagerLoadAsyncFast()
{
    _loadSceneFastAllowSceneActivation = false;
    StartCoroutine( loadSceneAsyncFast( "main" ) );
}

public IEnumerator loadSceneAsync( string a_scene )
{
    yield return null;
    AsyncOperation asyncOperation = SceneManager.LoadSceneAsync( a_scene, LoadSceneMode.Additive );
    asyncOperation.allowSceneActivation = true;

    bool l_isDone = true;
    while( l_isDone )
    {
        if (asyncOperation.progress >= 0.9f)
        {
            l_isDone = false;
        }
        yield return null;
    }
    yield return null;

    while (!asyncOperation.isDone){
        yield return null;
    }

    yield return null;

    unloadScene();
    yield return null;

    loadSceneAsyncFlag = true;
}

public IEnumerator loadSceneAsyncFast( string a_scene )
{
    yield return null;

    AsyncOperation asyncOperation = SceneManager.LoadSceneAsync( a_scene, LoadSceneMode.Additive );

    asyncOperation.allowSceneActivation = true;

    bool l_isDone = true;
    while( l_isDone )
    {
        if (asyncOperation.progress >= 0.9f)
        {
            l_isDone = false;
        }
        yield return null;
    }

    while (!asyncOperation.isDone){
        yield return null;
    }

    while (!_loadSceneFastAllowSceneActivation){
        yield return null;
    }

    _loadSceneFastFlag = true;
    unloadScene();

    loadSceneAsyncFlag = true;
}

上記のようなコードでアプリ起動時に

1.ロゴとメインを非同期で読み込みさせる
2.ロゴ表示中にメインの読み込みを進行させる
3.ロゴ表示終了で「_loadSceneFastAllowSceneActivation」を「true」にしメインの読み込みを完了させる

といった読み込み方法を行っております。

メインシーンにObject登録が多いためシーンを分割したのですが、エミュレーター上では1.5秒ほどでメインシーンの読み込み完了するのですが、
第6世代iPadでは読み込み完了までに20秒かかってしまいます。
改善として
・GameObjectをprefab化しシーン読み込み後に生成する方法で登録数を減す
・テストとして1画面のみの登録数に減す
・ロゴシーンを読み込まず、アプリ起動時にメインシーンの読み込みを行う
を試してみましたが、読み込み時間は変わらず20秒かかってしまいます。

登録数の問題ではないような気がしますが、シーン作成やアプリ起動時の読み込みタイミングなどで読み込み速度が変わるのでしょうか。
.unityファイルの容量は
ロゴ.unity:95.4KB
メイン.unity:1.01MB
になります。
unloadSceneを行った時や、画面遷移で時間をかけたくないため一つのシーンにまとめております。

こちら改善方法ご存じでしたら教えてください。

0

No Answers yet.

Your answer might help someone💌