我为场景视图中的某些游戏对象创建了一个编辑器,但只有在层次结构视图中选中时才会出现。下面是我的编辑器脚本。是我缺少的东西吗?
<Link to={{ pathname: '/details', query: { cardId: this.props.cardId } }}/>
我的非编辑器脚本是:
using UnityEditor;
using UnityEngine;
[CustomEditor(typeof(BezierCurve))]
public class BezierCurveInspector : Editor {
private BezierCurve curve;
private Transform handleTransform;
private Quaternion handleRotation;
private void OnSceneGUI () {
curve = target as BezierCurve;
handleTransform = curve.transform;
handleRotation = Tools.pivotRotation == PivotRotation.Local ?
handleTransform.rotation : Quaternion.identity;
Vector3 p0 = ShowPoint(0);
Vector3 p1 = ShowPoint(1);
Vector3 p2 = ShowPoint(2);
Handles.color = Color.white;
Handles.DrawLine(p0, p1);
Handles.DrawLine(p1, p2);
}
private Vector3 ShowPoint (int index) {
Vector3 point = handleTransform.TransformPoint(curve.points[index]);
EditorGUI.BeginChangeCheck();
point = Handles.DoPositionHandle(point, handleRotation);
if (EditorGUI.EndChangeCheck()) {
Undo.RecordObject(curve, "Move Point");
EditorUtility.SetDirty(curve);
curve.points[index] = handleTransform.InverseTransformPoint(point);
}
return point;
}
}