3

这是我的代码,

 CoreGlobal.OnMobile = EditorGUILayout.Toggle("Mobile Build", CoreGlobal.OnMobile);

         if (Selection.activeGameObject && Selection.activeGameObject.tag == "CBC")
         {
             selectedTransform = Selection.activeGameObject.transform;
             fold = EditorGUILayout.InspectorTitlebar(fold, selectedTransform);
             if (fold)
             {
                 selectedTransform.position =
                     EditorGUILayout.Vector3Field("Position", selectedTransform.position);
                 EditorGUILayout.Space();
                 rotationComponents =
                     EditorGUILayout.Vector4Field("Detailed Rotation", QuaternionToVector4(selectedTransform.localRotation));
                 EditorGUILayout.Space();
                 selectedTransform.localScale =
                     EditorGUILayout.Vector3Field("Scale", selectedTransform.localScale);
             }
             selectedTransform.localRotation = ConvertToQuaternion(rotationComponents);
             EditorGUILayout.Space();
         }

这是我在编辑器窗口中的代码,onGUI 函数。

我正在尝试为代码创建撤消。我不确定如何撤消 Toogle 值。 Undo.RecordObject(OBJECT, STRING);

有什么方法可以将 bool 更改为 Object 以便撤消它?如果有人能让我开始只是为了布尔,我可以做剩下的。

4

1 回答 1

0

我不认为这是一个完美的答案,但你可以用这个回调做点什么。它不是一个完美的解决方案,但它应该是一个开始。

http://docs.unity3d.com/ScriptReference/Undo-undoRedoPerformed.html

然后你可以用一个虚拟对象注册一个撤消,然后以某种方式弄清楚如何检测完成了什么样的撤消?

于 2015-05-29T00:07:56.713 回答