Debug.DrawLine(worldPos1,worldPos2,Color.yellow); } 1. 2. 3. 4. (2)Gizmos.Draw OnDrawGizmos /OnDrawGizmosSelected里调用 =2=只在Scene窗口里显示 =3=并且不能设置材质 publicvoidOnDrawGizmosSelected(){ Gizmos.DrawLine(Vector3.zero,newVector3(0,3f,0)); } 1. 2. 3. (3)Graphic.DrawMe...
与Editor有关的脚本必须放在Editor文件夹下,在Assets目录下创建一个Editor文件夹,并且在它里面新建一个LineInspector脚本。 自定义的inspector必须继承UnityEditor.Editor。并且要为它添加UnityEditor.CustomEditor属性。这样Unity才知道选中Line的时候要使用我们自定义的editor。 ? 1 2 3 4 5 6 usingUnityEditor; usingUn...
在Editor文件夹内新建MyCustomOnDrawGizmos usingUnityEngine;usingUnityEditor;publicclassGizmosTest{//表示物体显示并且被选择的时候,绘制Gizmos[DrawGizmo(GizmoType.Active|GizmoType.Selected)]//第一个参数需要指定目标类,目标类需要挂载在场景对象中privatestaticvoidMyCustomOnDrawGizmos(TargetExampletarget,GizmoTypegi...
注:EditorWindow的绘制只是为了显示信息方便,Editor绘制方式见:Unity Editor 编辑器扩展功能详解(3) 2. Line/Dotted Line(线段/虚线) 关键字: Handles.DrawLine,Handles.DrawDottedLine 样例: 示例代码: //1.from 2.to 3.thickness(厚度)决定线段厚度Handles.DrawLine(Vector3.zero,newVector3(-1,1,1),2f);...
unity EditorWindow 绘制时间刻度 最终效果图 绘制时间刻度其实主要靠,Handles类的DrawLine(),Handles类里还封装了许多其它的图形绘制方法,如画扇形等 知道这个方法就很简单了 privatevoidDrawfraemLine(Rect rect) { Handles.BeginGUI(); Handles.color=newColor(0,1,0,0.4f);floatstep =8;intIndex =0;for(...
UnityEditor UnityEngine Other Handles.DrawLine public static void DrawLine (Vector3 p1, Vector3 p2); 描述 绘制一条从 p1 到p2 的线。 \ 在场景视图中绘制线条。 // Draw lines to the connected game objects that a script has. // if the target object doesnt have any game objects attached...
但是前者插件资源过多,我不喜欢丢这么大一个插件包在工程里,后者内部结构复杂且只能在编辑器里动态定义路径(Editor还疯狂报红错),总之就是用的都不咋顺心 _(:з)∠)_ 于是乎看了这两套代码后我觉得路点系统这个东西只从概念上来看并不复杂,索性就自己写一个好了。
Handles.DrawLine(myObject.transform.position, myObject.transform.position + Vector3.up * 10); } } public class MySceneObject : MonoBehaviour { // 类定义 } 4. 编辑器窗口扩展 通过继承EditorWindow类,可以创建自定义的编辑器窗口。这些窗口可以包含复杂的UI元素,如按钮、文本框、列表等。
UnityEditor UnityEngine Other Debug.DrawLine public static void DrawLine (Vector3 start, Vector3 end, Color color= Color.white, float duration= 0.0f, bool depthTest= true); 参数 start 应作为该直线起始点的世界空间中的点。 end 应作为该直线结束点的世界空间中的点。 color 该直线的颜色。
Handles.DrawLine(p1, p2); } privateVector3 ShowPoint (intindex) { Vector3 point = handleTransform.TransformPoint(curve.points[index]); EditorGUI.BeginChangeCheck(); point = Handles.DoPositionHandle(point, handleRotation); if(EditorGUI.EndChangeCheck()) { ...