Skip to content

Instantly share code, notes, and snippets.

@Magnagames
Created July 4, 2016 21:48
Show Gist options
  • Save Magnagames/1aa8ddfe7583900ed1a26c944aecd0d3 to your computer and use it in GitHub Desktop.
Save Magnagames/1aa8ddfe7583900ed1a26c944aecd0d3 to your computer and use it in GitHub Desktop.
using UnityEngine;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
public class GameData : SingletonMonoBehaviour<GameData>{
//セーブしたいデータを定義するクラス
//コンストラクタで値を初期化
class SaveData: SavableSingleton<SaveData>{
public Player Player;
public float VolumeSE;
public float VolumeBGM;
public SaveData(){
Player = new Player();
VolumeSE=0.5f;
VolumeBGM=0.5f;
}
}
public static void Save(){
SaveData.Save ();
}
public static void Reset(){
SaveData.Reset ();
}
public static float VolumeSE{
get{return SaveData.Instance.VolumeSE;}
set{SaveData.Instance.VolumeSE = value; }
}
public static float VolumeBGM{
get{return SaveData.Instance.VolumeBGM;}
set{SaveData.Instance.VolumeBGM = value; }
}
public static Player Player{
get{return SaveData.Instance.Player;}
set{ SaveData.Instance.Player = value; }
}
public void Awake()
{
if(this != Instance)
{
Destroy(this);
return;
}
DontDestroyOnLoad(this.gameObject);
}
void Start(){
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment