Skip to content

Instantly share code, notes, and snippets.

@EsProgram
Created December 3, 2014 00:42
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 EsProgram/83ed8a8d758b4fa186e3 to your computer and use it in GitHub Desktop.
Save EsProgram/83ed8a8d758b4fa186e3 to your computer and use it in GitHub Desktop.
セーブ/ロード
using System.Collections;
using System.IO;
using System.Xml.Serialization;
using UnityEngine;
public class GUI_Pass : MonoBehaviour
{
private string pass = string.Empty;
private void OnGUI()
{
pass = GUILayout.TextField(pass, 10);
if(GUILayout.Button("ロード"))
{
using(Stream rs = File.Open("sv_data.xml", FileMode.Open))
{
XmlSerializer serializer = new XmlSerializer(typeof(string));
pass = (string)serializer.Deserialize(rs);
}
}
if(GUILayout.Button("セーブ"))
{
if(pass.Length >= 6)
using(Stream ws = File.Open("sv_data.xml", FileMode.Create))
{
XmlSerializer serializer = new XmlSerializer(typeof(string));
serializer.Serialize(ws, pass);
}
}
if(GUILayout.Button("終了"))
{
Application.Quit();
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment