You can use this class in your customer editor scripts to support
persisting changes applied during play mode. It only works on the
component that the custom inspector is handling but supports changes
in multiple objects during one session.
Inheritance Hierarchy
NarayanaGames.UnityEditor.Common PlayModeChangesHelper
Namespace: NarayanaGames.UnityEditor.Common
Assembly: Assembly-CSharp-Editor (in Assembly-CSharp-Editor.dll) Version: 0.0.0.0
Syntax
Remarks
Examples
using NarayanaGames.UnityEditor.Common; // on top of the file private static Dictionary<Object, PlayModeChangesHelper> playModeChangesHelpers = new Dictionary<Object, PlayModeChangesHelper>(); private PlayModeChangesHelper PlayModeChangesHelper { get { if (!playModeChangesHelpers.ContainsKey(target)) { playModeChangesHelpers[target] = new PlayModeChangesHelper(target, "PersistChanges_YourComponentName"); } return playModeChangesHelpers[target]; } } void OnEnable() { // ... whatever you need to do in OnEnable ;-) PlayModeChangesHelper.InspectorEnabled(this.target); } public override void OnInspectorGUI() { serializedObject.Update(); // DrawCustomGUI(); // ... or however you do this ;-) // it is recommended that you put the persist GUI at the end of your inspector PlayModeChangesHelper.DrawInspectorGUI(playModeChangesHelpers); serializedObject.ApplyModifiedProperties(); }
See Also