- BeginHorizontal
- BeginScrollView
- BeginToggleGroup
- BeginVertical
- BoundsField
- ColorField
- CurveField
- EndHorizontal
- EndScrollView
- EndToggleGroup
- EndVertical
- EnumPopup
- FloatField
- Foldout
- InspectorTitlebar
- IntField
- IntPopup
- IntSlider
- LabelField
- LayerField
- MinMaxSlider
- ObjectField
- PasswordField
- Popup
- PrefixLabel
- PropertyField
- RectField
- SelectableLabel
- Slider
- Space
- TagField
- TextArea
- TextField
- Toggle
- Vector2Field
- Vector3Field
- Vector4Field
EditorGUILayout.CurveField 曲线字段
static function CurveField (value : AnimationCurve, params options : GUILayoutOption[]) : AnimationCurve
static function CurveField (label : string, value : AnimationCurve, params options : GUILayoutOption[]) : AnimationCurve
static function CurveField (label : GUIContent, value : AnimationCurve, params options : GUILayoutOption[]) : AnimationCurve
static function CurveField (value : AnimationCurve, color : Color, ranges : Rect, params options : GUILayoutOption[]) : AnimationCurve
static function CurveField (label : string, value : AnimationCurve, color : Color, ranges : Rect, params options : GUILayoutOption[]) : AnimationCurve
static function CurveField (label : GUIContent, value : AnimationCurve, color : Color, ranges : Rect, params options : GUILayoutOption[]) : AnimationCurve
Parameters参数
-
labelOptional label in front of the field. // 字段前面的可选标签。
-
valueThe value to edit. // 编辑的值
- colorThe color to show the curve with. // 曲线显示的颜色
- rangesOptional rectangle that the curve is restrained within.
可选曲线被约束的矩形 -
optionsAn optional list of layout options that specify extra layouting properties. Any values passed in here will override settings defined by the style. See Also: GUILayout.Width, GUILayout.Height, GUILayout.MinWidth, GUILayout.MaxWidth, GUILayout.MinHeight, GUILayout.MaxHeight, GUILayout.ExpandWidth, GUILayout.ExpandHeight
指定额外布局属性的可选列表。这里传递任意值,将覆盖样式定义的设置。
AnimationCurve - The curve edited by the user.
返回Color,由用户输入的值。
Description描述
Make a field for editing an AnimationCurve.
制作一个用于编辑动画曲线的字段。
Create an animation on the different axis and assign it to a GameObject.
在不同轴创建动画并指定到游戏物体。
// Makes the selected GameObject follow the animation curve.
//制作选择的游戏物体跟随动画曲线。
// Usage: Generate the curves for X,Y and Z axis of your desired GameObject
// Select an Object and click Generate Curve.
// Press Play and see your object moving.
//用法:为游戏物体创建曲线X,Y 和 Z轴,选择物体并点击生成曲线。按播放看物体移动
class FollowCurve extends EditorWindow {
var curveX : AnimationCurve = AnimationCurve.Linear(0,0,10,10);
var curveY : AnimationCurve = AnimationCurve.Linear(0,0,10,10);
var curveZ : AnimationCurve = AnimationCurve.Linear(0,0,10,10);
@MenuItem("Examples/Create Curve For Object")
static function Init() {
var window = GetWindow(FollowCurve);
window.Show();
}
function OnGUI() {
curveX = EditorGUILayout.CurveField("Animation on X", curveX);
curveY = EditorGUILayout.CurveField("Animation on Y", curveY);
curveZ = EditorGUILayout.CurveField("Animation on Z", curveZ);
if(GUILayout.Button("Generate Curve"))
AddCurveToSelectedGameObject();
}
function AddCurveToSelectedGameObject() {
if(Selection.activeGameObject) {
var comp : FollowAnimationCurve =
Selection.activeGameObject.AddComponent(FollowAnimationCurve);
comp.SetCurves(curveX, curveY, curveZ);
} else {
Debug.LogError("No Game Object selected for adding an animation curve");
}
}
}
And the script that works with the example:
脚本工作的例子:
// This script has to go outside of the Editor Folder.
//这个脚本放在编辑器文件的外面
var curveX : AnimationCurve;
var curveY : AnimationCurve;
var curveZ : AnimationCurve;
function SetCurves(xC : AnimationCurve, yC : AnimationCurve, zC : AnimationCurve) {
curveX = xC;
curveY = yC;
curveZ = zC;
}
function Update() {
transform.position = Vector3(curveX.Evaluate(Time.time),
curveY.Evaluate(Time.time),
curveZ.Evaluate(Time.time));
}