Created
May 16, 2016 05:44
-
-
Save uranuno/8c74d73c1696ea60fd1a90954d53e224 to your computer and use it in GitHub Desktop.
Unity SceneModule
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using UnityEngine; | |
using UnityEngine.SceneManagement; | |
/// <summary> | |
/// Scene単位でパーツを管理する。 | |
/// 型名 = Scene名 | |
/// </summary> | |
public class SceneModule<T> : MonoBehaviour where T : SceneModule<T> | |
{ | |
public static T current { get; private set; } | |
static string m_SceneName { get { return typeof(T).Name; } } | |
void Awake () | |
{ | |
current = (T)this; | |
} | |
public static AsyncOperation LoadAsync () | |
{ | |
if (current != null) | |
return null; | |
else | |
return SceneManager.LoadSceneAsync (m_SceneName, LoadSceneMode.Additive); | |
} | |
public static void Unload () | |
{ | |
if (current == null) | |
return; | |
SceneManager.UnloadScene (m_SceneName); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment