Skip to content

Instantly share code, notes, and snippets.

@urahimono urahimono/SceneTable.cs
Last active Apr 6, 2017

Embed
What would you like to do?
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
You can’t perform that action at this time.