publicclassSaveEditorWindow:EditorWindow{privateSerializedObjectserObj;privatestaticSaveEditorWindowinstance;[MenuItem("SaveEditor/editor window")]privatestaticvoidShowWindow(){instance=EditorWindow.GetWindow<SaveEditorWindow>();instance.Show();}//显示时调用privatevoidOnEnable(){serObj=newSerializedObject(this);comSP=serObj.FindProperty("components");saveDP=serObj.FindProperty("SaveDuringPlay");EditorApplication.playModeStateChanged+=OnChangePlayModeState;//Debug.Log("OnEnable");}//绘制窗体内容privatevoidOnGUI(){EditorGUILayout.LabelField("Welcome using DemonViglu's SaveEditor",EditorStyles.boldLabel);serObj.Update();EditorGUILayout.PropertyField(comSP);EditorGUILayout.PropertyField(saveDP);serObj.ApplyModifiedProperties();if(GUILayout.Button("Save")){Check();}if(!EditorApplication.isPlaying&&GUILayout.Button("Load")){OnChangePlayModeState(PlayModeStateChange.ExitingPlayMode);}}//固定帧数调用privatevoidUpdate(){if(SaveDuringPlay&&EditorApplication.isPlaying){Check();}}//隐藏时调用privatevoidOnDisable(){//Debug.Log("OnDisable");}//销毁时调用privatevoidOnDestroy(){//Debug.Log("OnDestroy");}}