本文整理匯總了C#中UnityEditor.SerializedProperty.Clamp方法的典型用法代碼示例。如果您正苦於以下問題:C# SerializedProperty.Clamp方法的具體用法?C# SerializedProperty.Clamp怎麽用?C# SerializedProperty.Clamp使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類UnityEditor.SerializedProperty
的用法示例。
在下文中一共展示了SerializedProperty.Clamp方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。
示例1: OnGUI
public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
{
drawPrefixLabel = false;
Begin(position, property, label);
float min = ((SliderAttribute)attribute).min;
float max = ((SliderAttribute)attribute).max;
EditorGUI.BeginChangeCheck();
currentPosition.height = 16;
object value = property.GetValue();
if (value is int) {
property.SetValue(EditorGUI.IntSlider(currentPosition, label, (int)value, (int)min, (int)max));
}
else if (value is float) {
property.SetValue(EditorGUI.Slider(currentPosition, label, (float)value, min, max));
}
else if (value is double) {
property.SetValue(EditorGUI.Slider(currentPosition, label, (float)(double)value, min, max));
}
else {
EditorGUI.HelpBox(currentPosition, "The type of the field must be numerical.", MessageType.Error);
}
if (EditorGUI.EndChangeCheck()) {
property.Clamp(min, max);
}
End();
}
示例2: OnGUI
public override void OnGUI(Rect position, SerializedProperty property, GUIContent label) {
drawPrefixLabel = false;
Begin(position, property, label);
float min = ((ClampAttribute)attribute).min;
float max = ((ClampAttribute)attribute).max;
EditorGUI.BeginChangeCheck();
EditorGUI.PropertyField(currentPosition, property, label, true);
if (EditorGUI.EndChangeCheck()) {
property.Clamp(min, max);
}
End();
}