unity 编辑器扩展控件属性变化监听 BeginChangeCheck

来源:互联网 发布:painter mac 2017 破解 编辑:程序博客网 时间:2024/05/22 12:09
BeginChangeCheck 可以监听段EditorGUI 控件属性有没有改变
如果 有变化 EditorGUI.EndChangeCheck 会返回true

<span style="white-space:pre"></span>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));        }

这样即使没有rotateIndex 没有变化 if 中的逻辑就不会每个渲染帧都执行一次了。

0 0
原创粉丝点击