Skip to content

Instantly share code, notes, and snippets.

@urahimono
Last active April 6, 2017 13:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save urahimono/333ab564287bbaaeaf8815839de8d242 to your computer and use it in GitHub Desktop.
Save urahimono/333ab564287bbaaeaf8815839de8d242 to your computer and use it in GitHub Desktop.
GGJ2017で使ったシーン管理システム
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