Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
ISerializationCallbackReceiverを使用したバージョン
using UnityEngine;
using UnityEditor;
public class EditorWindowTest : EditorWindow ,ISerializationCallbackReceiver
{
public static string message;
[MenuItem("Window/Show")]
static void Init()
{
var window = EditorWindow.CreateInstance<EditorWindowTest> ();
EditorWindowTest.message = "C";
window.Show ();
}
void OnGUI()
{
GUILayout.Label (EditorWindowTest.message);
if (GUILayout.Button ("PUSH")) { EditorWindowTest.message += "#"; }
}
public void OnBeforeSerialize ()
{
using (System.IO.StreamWriter writer = new System.IO.StreamWriter ("Temp/EditorWindowTest")) {
writer.WriteLine (EditorWindowTest.message);
}
}
public void OnAfterDeserialize ()
{
using (System.IO.StreamReader reader = new System.IO.StreamReader ("Temp/EditorWindowTest")) {
EditorWindowTest.message = reader.ReadLine ();
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment