我最近制作了一个自定义检视面板,但我发现当我在检视面板中编辑变量时,我的 OnValidate() 回调函数没有被调用。你有什么想法如何保留我使用的自定义检视面板并使我的 OnValidate() 回调函数能够被再次调用吗?
我最近制作了一个自定义检视面板,但我发现当我在检视面板中编辑变量时,我的 OnValidate() 回调函数没有被调用。你有什么想法如何保留我使用的自定义检视面板并使我的 OnValidate() 回调函数能够被再次调用吗?
public class Original : MonoBehaviour {
// Used for the user to input their board section width and height.
[Tooltip("The desired Camera Width.")]
public float cameraWidth;
}
现在在我的自定义检视面板中,我有这个:
pubilc class Original_Editor : Editor{
public override void OnInspectorGUI(){
serializedObject.Update();
// Get the camera width.
SerializedProperty width = serializedObject.FindProperty("cameraWidth");
// Set the layout.
EditorGUILayout.PropertyField(width);
// Clamp the desired values
width.floatValue = Mathf.Clamp((int)width.floatValue, 0, 9999);
// apply
serializedObject.ApplyModifiedProperties();
}
}