Last active
April 6, 2017 13:08
-
-
Save urahimono/333ab564287bbaaeaf8815839de8d242 to your computer and use it in GitHub Desktop.
GGJ2017で使ったシーン管理システム
This file contains 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 System.Linq; | |
public enum EScene | |
{ | |
Initialize, | |
Title, | |
Gameplay, | |
Edit, | |
Shop, | |
Tutorial, | |
Credit, | |
Logo, | |
CommingSoon, | |
} | |
[CreateAssetMenu( menuName = "GGJ/Create SceneTable", fileName = "SceneTable" )] | |
public class SceneTable : ScriptableObject | |
{ | |
private static readonly string RESOURCE_PATH = "Table/SceneTable"; | |
private static SceneTable s_instance = null; | |
public static SceneTable Instance | |
{ | |
get | |
{ | |
if( s_instance == null ) | |
{ | |
s_instance = Resources.Load( RESOURCE_PATH ) as SceneTable; | |
} | |
return s_instance; | |
} | |
} | |
[SerializeField, EnumListLabel( typeof(EScene) )] | |
private SceneData[] m_sceneList = null; | |
public SceneData GetSceneData( EScene i_scene ) | |
{ | |
int index = (int)i_scene; | |
return m_sceneList.Length > index ? m_sceneList[ index ] : new SceneData(); | |
} | |
public SceneData GetSceneData( string i_sceneName ) | |
{ | |
return m_sceneList.FirstOrDefault( value => value.m_name == i_sceneName ); | |
} | |
} // class SceneTable | |
[System.Serializable] | |
public struct SceneData | |
{ | |
[SerializeField] | |
public string m_name; | |
[SerializeField] | |
public AudioClip m_bgm; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment