CurveField
示例程序 | |
---|---|
说明 | 生成控制和编辑 AnimationCurve 动画曲线类的区域 |
用法
public static AnimationCurve CurveField(AnimationCurve value, params GUILayoutOption[] options);
public static AnimationCurve CurveField(string label, AnimationCurve value, params GUILayoutOption[] options);
public static AnimationCurve CurveField(GUIContent label, AnimationCurve value, params GUILayoutOption[] options);
public static AnimationCurve CurveField(AnimationCurve value, Color color, Rect ranges, params GUILayoutOption[] options);
public static AnimationCurve CurveField(string label, AnimationCurve value, Color color, Rect ranges, params GUILayoutOption[] options);
public static AnimationCurve CurveField(GUIContent label, AnimationCurve value, Color color, Rect ranges, params GUILayoutOption[] options);
参数
label
对应的标签名称。
value
该区域控制的颜色变量。
color
显示曲线的颜色。
ranges
(可选)限制曲线的矩形。
options
(可选)用于指定额外的布局属性,该参数将覆盖默认样式。
示例
public override void OnInspectorGUI () {
// First reload, no label, no extra options
_target.CurveFirst = EditorGUILayout.CurveField (_target.CurveFirst);
// Second reload, with a label and an expanded width
_target.CurveSecond = EditorGUILayout.CurveField ("Curve Second", _target.CurveSecond, GUILayout.ExpandWidth (true));
// Third reload, with a label, a tooltip and a size of 400 pixels * 100 pixels
var guiContent = new GUIContent ("Curve Third", "This is the third curve.");
var guiLayoutOptions = new GUILayoutOption [] {
GUILayout.Width(400),
GUILayout.Height(100)
};
_target.CurveThird = EditorGUILayout.CurveField (guiContent, _target.CurveThird, guiLayoutOptions);
// Forth reload, painted in red and restrained between (0, 0) to (15, 15)
_target.CurveForth = EditorGUILayout.CurveField (
"CurveForth",
_target.CurveForth,
Color.red,
new Rect(0, 0, 15, 15),
GUILayout.Height(200)
);
}
编译结果如下:
后两条曲线的不受限、受限情况如下: