HandlesTest.cs一定要放在Editor目录下。
using UnityEngine; using UnityEditor; using System.Collections; [CustomEditor(typeof(SolidArcExample))] public class HandlesTest : Editor { private SolidArcExample mTarget; private float viewDistance = 10f; void OnSceneGUI () { SolidArcExample mTarget = (SolidArcExample)target; Handles.color = new Color(0f, 1f, 1f, 0.2f); //颜色 Handles.DrawSolidArc (mTarget.transform.position, //中心点 mTarget.transform.up, //法线 -mTarget.transform.right, //起始位置 180, //弧度 viewDistance);//半径 Handles.color = Color.white; } }
using UnityEngine; using System.Collections; public class SolidArcExample : MonoBehaviour { }