unity undo 操作

来源:互联网 发布:手机 电脑 相册软件 编辑:程序博客网 时间:2024/06/03 20:47

Undo.RecordObject

记录 修改 单一属性的 方法
以设置GameObject的旋转为例

EditorGUI.BeginChangeCheck();rotateIndex = GUILayout.SelectionGrid(rotateIndex, new string[] { "0", "90", "180", "270" }, 4, GUILayout.ExpandWidth(true));if (EditorGUI.EndChangeCheck()){    int rotate = 0;    rotateSetting.TryGetValue(rotateIndex, out rotate);    Undo.RecordObject(rotateGo.transform, "rotateGo Rotation");    rotateGo.transform.localRotation = Quaternion.Euler(new Vector3(v.x, (float)rotate, v.z));}

只需要一条语句非常方便

0 0