Created
December 3, 2014 00:42
-
-
Save EsProgram/83ed8a8d758b4fa186e3 to your computer and use it in GitHub Desktop.
セーブ/ロード
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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