【Unity】Unity Gizmos扩展(圆弧、扇形、圆形)

使用 UnityEditor.Handles 为Unity Gizmos 实现的扩展:

  • GizmosX.DrawWireArc() :画圆弧线
  • GizmosX.DrawSolidArc() :画扇形
  • GizmosX.DrawWireDisc() :画空心圆
  • GizmosX.DrawSolidDisc() :画实心圆
// GizmosExtension.csnamespace UnityEngine
{/// <summary>/// Gizmos Extensions./// </summary>public static class GizmosX{/// <summary>/// Draw a circular arc in 3D space./// </summary>/// <param name="center">The center of the circle.</param>/// <param name="normal">The normal of the circle.</param>/// <param name="from">The direction of the point on the circle circumference, relative to the center, where the arc begins.</param>/// <param name="angle"> The angle of the arc, in degrees.</param>/// <param name="radius">The radius of the circle Note: Use HandleUtility.GetHandleSize where you might want to have constant screen-sized handles.</param>[System.Diagnostics.Conditional("UNITY_EDITOR")]public static void DrawWireArc(Vector3 center, Vector3 normal, Vector3 from, float angle, float radius){#if UNITY_EDITORUnityEditor.Handles.color = Gizmos.color;UnityEditor.Handles.DrawWireArc(center, normal, from, angle, radius);
#endif}/// <summary>/// Draw a circular sector (pie piece) in 3D space./// </summary>/// <param name="center">The center of the circle.</param>/// <param name="normal">The normal of the circle.</param>/// <param name="from">The direction of the point on the circle circumference, relative to the center, where the arc begins.</param>/// <param name="angle"> The angle of the arc, in degrees.</param>/// <param name="radius">The radius of the circle Note: Use HandleUtility.GetHandleSize where you might want to have constant screen-sized handles.</param>[System.Diagnostics.Conditional("UNITY_EDITOR")]public static void DrawSolidArc(Vector3 center, Vector3 normal, Vector3 from, float angle, float radius){#if UNITY_EDITORUnityEditor.Handles.color = Gizmos.color;UnityEditor.Handles.DrawSolidArc(center, normal, from, angle, radius);
#endif}/// <summary>/// Draw the outline of a flat disc in 3D space./// </summary>/// <param name="center">The center of the disc.</param>/// <param name="normal">The normal of the disc.</param>/// <param name="radius">The radius of the disc.</param>[System.Diagnostics.Conditional("UNITY_EDITOR")]public static void DrawWireDisc(Vector3 center, Vector3 normal, float radius){#if UNITY_EDITORUnityEditor.Handles.color = Gizmos.color;UnityEditor.Handles.DrawWireDisc(center, normal, radius);
#endif}/// <summary>/// Draw a solid flat disc in 3D space./// Note: Use HandleUtility.GetHandleSize where you might want to have constant screen-sized handles./// </summary>/// <param name="center">The center of the disc.</param>/// <param name="normal">The normal of the disc.</param>/// <param name="radius">The radius of the disc.</param>[System.Diagnostics.Conditional("UNITY_EDITOR")]public static void DrawSolidDisc(Vector3 center, Vector3 normal, float radius){#if UNITY_EDITORUnityEditor.Handles.color = Gizmos.color;UnityEditor.Handles.DrawSolidDisc(center, normal, radius);
#endif}/// <summary>/// Make a text label positioned in 3D space./// </summary>/// <param name="position">Position in 3D space as seen from the current handle camera.</param>/// <param name="text">Text to display on the label.</param>[System.Diagnostics.Conditional("UNITY_EDITOR")]public static void Label(Vector3 position, string text){#if UNITY_EDITORUnityEditor.Handles.color = Gizmos.color;UnityEditor.Handles.Label(position, text);
#endif}/// <summary>/// Make a text label positioned in 3D space.///  Note: Use HandleUtility.GetHandleSize where you might want to have constant screen-sized handles./// </summary>/// <param name="position">Position in 3D space as seen from the current handle camera.</param>/// <param name="content">Text, image and tooltip for this label.</param>/// <param name="style">The style to use. If left out, the label style from the current GUISkin is used.</param>[System.Diagnostics.Conditional("UNITY_EDITOR")]public static void Label(Vector3 position, GUIContent content, GUIStyle style){#if UNITY_EDITORUnityEditor.Handles.color = Gizmos.color;UnityEditor.Handles.Label(position, content, style);
#endif}}
}

【Unity】Unity Gizmos扩展(圆弧、扇形、圆形)相关推荐

  1. Unity Gizmos扩展:线框圆

    Unity Gizmos扩展:画一个线框圆 定义 圆由圆心位置与半径决定的 在Unity中画圆,由于需要跟随对象转动而转动,除了圆心位置和半径,还需要提供两个方向向量 有两条线,才有了决定一个面的基础 ...

  2. Unity Gizmos扩展:线框平面胶囊体

    Unity Gizmos扩展:线框平面胶囊体 定义(拆解): 如下图,平面胶囊体可以看作由两个半圆和连接半圆对应端点的两条线段组成. 因此画平面胶囊体需要参数: 胶囊体中心位置PosCenterPos ...

  3. Unity Gizmos扩展:线框胶囊体

    Unity Gizmos扩展:线框胶囊体 定义(拆解): 如下图,线框胶囊体可以看作由两个平面胶囊体和两个圆组成. 因此画平面胶囊体需要参数: 胶囊体中心位置PosCenterPos_{Center} ...

  4. 自定义Unity 容器的扩展 --- Unity Application Block Event Broker

    Unity快速入门的例子中有一个Block Event Broker通过对容器功能的扩展来实现事件截获,其中扩展的代码在项目EventBrokerExtension.该项目允许在应用程序种使用自定义的 ...

  5. unity shader 编辑器扩展类 ShaderGUI

    这应该unity5才出的新功能了,今天看文档时刚巧看到了,就来尝试了一下. 效果如图: shader 的编辑器扩展分为2种方法: 是通过UnityEditor下的ShaderGUI类来实现的,形式比较 ...

  6. Unity的Gizmos画线

    Unity的Gizmos画线 1效果图 2.核心代码 3,亲测可行 加粗样式 4,注意事项这个Gizmos模式下画线,需要打开Unity的Scene和G ame视图中的Gizmos选项,因此在编辑器下 ...

  7. Unity使用Shader快速制作一个圆形遮罩

    Unity使用Shader快速制作一个圆形遮罩 如何用Shader来做出圆形.切倒角和边缘虚化 Unity使用Shader快速制作一个圆形遮罩 橙子前言 一.创建Shader 二.创建Material ...

  8. java 画弧线_java画图基本操作-线/折线,圆弧/扇形,椭圆,文本

    /*** 画线/折线*/ private static voiddrawLine(Graphics g) { Graphics2D g2d=(Graphics2D) g.create();//抗锯齿 ...

  9. Unity Editor 编辑器扩展一 编辑器特殊文件夹及内置资源读取

    目录 目录 编辑器特殊文件夹及内置资源读取 编辑器相关文件夹 读取内置资源包 代码 Test1_1cs 代码Editor1_1cs 这个要放到Editor文件夹内 编辑器特殊文件夹及内置资源读取 使用 ...

最新文章

  1. 八零后高薪程序员感慨中年危机,月薪五万多,想要跳槽没地方!
  2. RStudio配置R程序包的默认下载源
  3. 201312-1- 出现次数最多的数
  4. UNITY Profiler 真机调试
  5. boost::type_erasure::binding_of相关的测试程序
  6. 改变ComboBox控件的高度
  7. python来构建多层网络
  8. java汉字偏旁拆分,常见部首的拆分
  9. 计算机科学在各专业领域中的应用,计算机科学在各专业领域中的应用
  10. 话里话外:明白比智慧更重要
  11. python去掉停用词_Python - 删除停用词
  12. 聚合广告SDK开发(一)——基础知识
  13. 内嵌PDF网页无法打开的解决办法
  14. java获取手机型号
  15. 新手学Unity3d的一些网站及相应学习路线
  16. 数据库原理-并发控制(2-封锁)
  17. 转载一篇c语言深度文章 《一个“蝇量级” C 语言协程库》
  18. 【渝粤题库】陕西师范大学163209 旅游企业战略管理
  19. 77、自动喷水灭火系统的巡查内容
  20. 智能书包方案——智能书包重力测量模块CSM92F32

热门文章

  1. 剑指Offer(Redis)——Redis做持久化
  2. jvm 性能调优工具之 jcmd
  3. 服装企业部署MES管理系统的五个原因
  4. banq 质疑Lambda架构
  5. 查询图片(根据自己的图片库)
  6. 全国大学生智能车室外光电组补充资料(偏方版本)
  7. 为了被重新聘用,被解雇员工竟黑了公司网络
  8. 串口服务器Moxa NPort 5650小结
  9. 选购集成墙面时这些顾虑有必要吗?
  10. stm32实现直流电机调速