Unity Gizmos可视化辅助工具

摘要:
6publicGameObjectobj2;78voidOnDrawGizmos()9{10Gizmos.color=color.green;obj2.transform.position);6voidOndrawGizmo()7{8Gizmos.color=color.gray;2使用System.Collections;

所有gizmo绘制需要在脚本的OnDrawGizmos或OnDrawGizmosSelected里函数完成。

  OnDrawGizmos在每帧调用。所有在OnDrawGizmos中渲染的gizmos都是可见的。

  OnDrawGizmosSelected仅在脚本附加的物体被选择时被调用。  

  1. Gizmos.DrawLine

  从obj1到obj2之间画一条绿色的线。

 1 using UnityEngine;
 2 using System.Collections;
 3 public class DrawLineText : MonoBehaviour {
 4 
 5     public GameObject obj1;
 6     public GameObject obj2;
 7     
 8     void OnDrawGizmos()
 9     {
10         Gizmos.color = Color.green;
11         Gizmos.DrawLine( obj1.transform.position , obj2.transform.position );
12     }
13 }

2.Gizmos.DrawRay

 从obj向上画一条长度为10的射线

 1 using UnityEngine;
 2 using System.Collections;
 3 public class DrawRayText : MonoBehaviour {
 4 
 5     public GameObject obj;
 6     void OnDrawGizmos()
 7     {
 8         Gizmos.color = Color.gray;
 9         Gizmos.DrawRay(obj.transform.position, Vector3.up * 10);  //10 是长度
10     }
11 }

3.Gizmos.DrawCube

 在(0,1,0)处画一个(1,1,1)大小的立方体

 1 using UnityEngine;
 2 using System.Collections;
 3 public class DrawCubeText : MonoBehaviour {
 4 
 5       void OnDrawGizmos()
 6     {
 7         Gizmos.color = Color.red;
 8         Gizmos.DrawCube(Vector3.up , Vector3.one);
 9     }
10 }

4.Gizmos.DrawIcon

 在(0,0,0)处生成一个名字为002IMgZLzy6Mro7r94Ka2&690.jpg的Icon ,此图片要放到Assets下的  Gizmos文件夹里才行。

1 using UnityEngine;
2 using System.Collections;
3 public class DrawIconText : MonoBehaviour {
4 
5       void OnDrawGizmos()
6     {
7         Gizmos.DrawIcon(Vector3.zero , "002IMgZLzy6Mro7r94Ka2&690.jpg");
8     }
9 }

免责声明:文章转载自《Unity Gizmos可视化辅助工具》仅用于学习参考。如对内容有疑问,请及时联系本站处理。

上篇微信支付开发(1) JS API支付ASP.NET Core MVC Razor小记下篇

宿迁高防,2C2G15M,22元/月;香港BGP,2C5G5M,25元/月 雨云优惠码:MjYwNzM=

相关文章

HTML_css3美化网页元素

一.span标签:能让某几个文字或者某个词语凸显出来 <p> 今天是11月份的<span>第一天</span>,地铁卡不打折了 </p> 二.字体风格 font-family:字体类型 font-size:字体大小 font-style:字体风格 font-weight:字体粗细 font: 风格 粗细 大小...

在ie和chrome浏览器中滚动条样式的设置

  1、IE下设置滚动条样式的属性 scrollbar-arrow-color: color; /*三角箭头的颜色*/scrollbar-face-color: color; /*立体滚动条的颜色(包括箭头部分的背景色)*/scrollbar-3dlight-color: color; /*立体滚动条亮边的颜色*/scrollbar-highlight-...

color

■ 定义color属性用于定义文本的颜色 ■ 使用说明开发中常见的三种颜色表示方式:   ▶ 预定义的颜色值:red, green, blue, pink等   ▶ 十六进制: #FF0000,#FF6600等(开发中最常用)   ▶ RGB代码:rgb(255,0,0) 或 rgb(100%,0%,0%) ■ 示例div { color: red...

C# chart控件基础使用

基本介绍:chart(图表) 功能:主要用来绘制折线图,柱状图与饼状图,也可达到动态效果(例如作示波器); 需要说明  一个chart可以包含多个chartArea。 chartArea是具体的坐标区域。 每一个chartArea主要包含X轴,Y轴,副X轴(上方),副Y轴(右方),绑定的线条,绑定的图例。  数据列可以有许多,只要将线条绑定到chartAr...

highcharts配置的效果如下

配置如下: function init(categoryArray,seriesData,month_first_day,month_last_day,currDay){ var chart = Highcharts.chart('container', { chart: { type: 'columnrange...

CSS 颜色相关

CSS预定义颜色表示法(就是使用颜色的英文): color:red; color:green; color:blue; CSS RGB颜色表示法: color:rgb(255,0,0); color:rgb(0,255,0); color:rgb(0,0,255); RGB颜色表示法就是红(R:red),绿(G:green),蓝(B:blue),这三原色混...