BeginChangeCheck, EndChangeCheck
示例程序 | |
---|---|
说明 | 包含的区域将会自动检查是否有数值变化 |
用法
BeginChangeCheck
标记自动检查区域的开始, EndChangeCheck
标记结束。当包含的区域有变化时, EndChangeCheck
返回 true
。
public static void BeginChangeCheck();
public static bool EndChangeCheck();
示例
void OnGUI () {
EditorGUI.BeginChangeCheck ();
_bound = EditorGUI.BoundsField (new Rect (5, 5, 200, 34), _bound);
if (EditorGUI.EndChangeCheck ()) {
ShowNotification (new GUIContent ("Something changed."));
}
_color = EditorGUI.ColorField (new Rect (5, 44, 200, 17), _color);
EditorGUI.BeginChangeCheck ();
_int = EditorGUI.IntSlider (new Rect(5, 66, 200, 17), _int, -5, 5);
if (EditorGUI.EndChangeCheck ()) {
ShowNotification (new GUIContent ("Something changed."));
}
}
窗口中共绘制了三个区域,其中 BoundsField
和 IntSlider
会被检查是否发生变化,变化时窗口中出现通知。而 ColorField
变化时不会出现通知。