LoginSignup
33
24

More than 5 years have passed since last update.

UnityでNowLoading画面を作る(C#版)

Posted at

ゲームのよくあるローディング画面を作りたい

http://gametukurikata.com/program/nowloading
を参考にした。しかし記載されていたのがjavascript版であった為、C#版を作成してみた。

LoadingScene.cs
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
using UnityEngine.SceneManagement;

public class LoadingScene : MonoBehaviour {

    private AsyncOperation async;
    public GameObject LoadingUi;
    public Slider Slider;

    public void LoadNextScene() {
        LoadingUi.SetActive(true);
        StartCoroutine(LoadScene());
    }

    IEnumerator LoadScene() {
        async = SceneManager.LoadSceneAsync("[シーン名]");

        while (!async.isDone) {
            Slider.value = async.progress;
            yield return null;
        }
    }
}

実行結果

PCだと読み込みが早すぎてよく分からないが、こんな感じでロード画面を挟める。
load.gif
※読み込み後のシーンは気にしないでください。

33
24
1

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
33
24