I have been tackling this issue for a while but I cant get any results. I get the “Happened” messaged on the console, and if I go to the Edit>Undo, i see “testing” after it, meaning it recorded the change.
But when I press it, or do Ctrl-Z nothing happens. The bool testing has to be public and static because I also want to change her throght a MenuItem.
I have tried multiple approaches this was one of them
using UnityEngine;
using System.Collections;
using UnityEditor;
public class MapMaker2D : EditorWindow {
//instance of this script
public static MapMaker2D instance;
//testbool
public static bool testing;
//runs whenever the window is created
void OnEnable()
{
//sets instance of mapmaker
instance = this;
}
void OnGUI()
{
EditorGUI.BeginChangeCheck ();
bool atesting=EditorGUILayout.Toggle (new GUIContent("testing","testing variable"),testing);
if (EditorGUI.EndChangeCheck ()) {
Debug.Log ("Happened");
Undo.RegisterCompleteObjectUndo(this, "testing");
testing=atesting;
}
}
}