Hi all !
Maybe I’m stupid, but I can’t manage to use Undo … I’ve tried many things, RecordObject, RecordObjects and other things, tried SetDirty, Repaint, etc … Nothing.
This little example doesn’t work … Can you help me ?
using UnityEngine;
using UnityEditor;
using System.Collections;
public class MyWindow : EditorWindow
{
[MenuItem("Shudrum/My window")]
public static void ShowWindow()
{
EditorWindow thisWindow = EditorWindow.GetWindow(typeof(MyWindow));
GUIContent title = new GUIContent();
title.text = "Toolbar";
thisWindow.titleContent = title;
}
void OnGUI()
{
if (GUI.Button(new Rect(0, 0, 32, 32), "Test")) {
Undo.RecordObjects(Selection.gameObjects, "Translate");
foreach (GameObject currentGameObject in Selection.gameObjects) {
currentGameObject.transform.position += Vector3.forward;
}
}
}
}
Thank you !