Created
January 31, 2017 14:29
-
-
Save tsubaki/de7690f86705ef404580aff4c3225877 to your computer and use it in GitHub Desktop.
ISerializationCallbackReceiverを使用したバージョン
This file contains 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 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