Skip to content

Instantly share code, notes, and snippets.

@Magnagames
Last active December 5, 2019 12:39
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Magnagames/4e69ec10d42485c6506561e4befe1f0b to your computer and use it in GitHub Desktop.
Save Magnagames/4e69ec10d42485c6506561e4befe1f0b to your computer and use it in GitHub Desktop.
using UnityEngine;
using System.Collections;
using System.Collections.Generic;
public class Test : MonoBehaviour {
[System.Serializable]
public class Player{
[SerializeField]
public int hp;
public float atk;
public string name;
public List<string> items;
public Player(){
items = new List<string>();
items.Add("ポーション");
items.Add("エーテル");
items.Add("エリクサー");
hp=10;
atk = 100f;
name = "クラウド";
}
}
// Use this for initialization
void Start () {
//セーブデータの設定
SaveData.SetInt ("i", 10);
SaveData.SetClass<Player> ("p1", new Player ());
SaveData.Save ();
Player getPlayer = SaveData.GetClass<Player> ("p1", new Player ());
Debug.Log ("取得したint値は" + SaveData.GetInt ("i"));
Debug.Log (getPlayer.name);
Debug.Log (getPlayer.items.Count + "こアイテムを持ってます");
Debug.Log (getPlayer.items[0] + getPlayer.items[1] + getPlayer.items[2] );
}
// Update is called once per frame
void Update () {
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment