您最多选择25个主题
主题必须以中文或者字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符
77 行
2.6 KiB
77 行
2.6 KiB
using UnityEngine;
|
|
using UnityEngine.Experimental.Rendering;
|
|
|
|
namespace UnityEditor.Experimental.Rendering
|
|
{
|
|
[VolumeParameterDrawer(typeof(ClampedFloatParameter))]
|
|
sealed class ClampedFloatParameterDrawer : VolumeParameterDrawer
|
|
{
|
|
public override bool OnGUI(SerializedDataParameter parameter, GUIContent title)
|
|
{
|
|
var value = parameter.value;
|
|
|
|
if (value.propertyType != SerializedPropertyType.Float)
|
|
return false;
|
|
|
|
var o = parameter.GetObjectRef<ClampedFloatParameter>();
|
|
|
|
if (o.clampMode == ParameterClampMode.MinMax)
|
|
{
|
|
EditorGUILayout.Slider(value, o.min, o.max, title);
|
|
value.floatValue = Mathf.Clamp(value.floatValue, o.min, o.max);
|
|
}
|
|
else if (o.clampMode == ParameterClampMode.Min)
|
|
{
|
|
float v = EditorGUILayout.FloatField(title, value.floatValue);
|
|
value.floatValue = Mathf.Max(v, o.min);
|
|
}
|
|
else if (o.clampMode == ParameterClampMode.Max)
|
|
{
|
|
float v = EditorGUILayout.FloatField(title, value.floatValue);
|
|
value.floatValue = Mathf.Min(v, o.max);
|
|
}
|
|
else
|
|
{
|
|
return false;
|
|
}
|
|
|
|
return true;
|
|
}
|
|
}
|
|
|
|
[VolumeParameterDrawer(typeof(InstantClampedFloatParameter))]
|
|
sealed class InstantClampedFloatParameterDrawer : VolumeParameterDrawer
|
|
{
|
|
public override bool OnGUI(SerializedDataParameter parameter, GUIContent title)
|
|
{
|
|
var value = parameter.value;
|
|
|
|
if (value.propertyType != SerializedPropertyType.Float)
|
|
return false;
|
|
|
|
var o = parameter.GetObjectRef<InstantClampedFloatParameter>();
|
|
|
|
if (o.clampMode == ParameterClampMode.MinMax)
|
|
{
|
|
EditorGUILayout.Slider(value, o.min, o.max, title);
|
|
value.floatValue = Mathf.Clamp(value.floatValue, o.min, o.max);
|
|
}
|
|
else if (o.clampMode == ParameterClampMode.Min)
|
|
{
|
|
float v = EditorGUILayout.FloatField(title, value.floatValue);
|
|
value.floatValue = Mathf.Max(v, o.min);
|
|
}
|
|
else if (o.clampMode == ParameterClampMode.Max)
|
|
{
|
|
float v = EditorGUILayout.FloatField(title, value.floatValue);
|
|
value.floatValue = Mathf.Min(v, o.max);
|
|
}
|
|
else
|
|
{
|
|
return false;
|
|
}
|
|
|
|
return true;
|
|
}
|
|
}
|
|
}
|