赞
踩
由于前者实用性不高,不做过多讲解。采用这样样的方式进行操控就可以
public GameObject ball;
ball.transform.position = transform.InverseTransformPoint(
transform.GetComponent<MeshFilter>().sharedMesh.vertices[10]);//10为随便举的例子
void OnDrawGizmos() { Debug.Log("beging to draw"); Gizmos.color = Color.red;//设置颜色 /* * 在起初找点的范围时 * 采用for循环 确定某一个区域(不断缩小区域) * 然后再精确的查找 */ for (int i = 729; i < 730; i += 2) { Gizmos.DrawSphere(transform.TransformPoint( gameObject.GetComponent<MeshFilter>().sharedMesh.vertices[i - 1]), 0.001f); Gizmos.DrawSphere(transform.TransformPoint( gameObject.GetComponent<MeshFilter>().sharedMesh.vertices[i]), 0.001f); } Gizmos.DrawSphere(transform.TransformPoint( gameObject.GetComponent<MeshFilter>().sharedMesh.vertices[761]), 0.001f); }
与OnDrawGizmos函数相似,但该函数仅在物体被选中时被执行,即:其挂载的物体被选中,执行该函数。
官方示例:
using UnityEngine;
public class gizmoTest : MonoBehaviour
{
public float explosionRadius = 5.0f;
void OnDrawGizmosSelected()
{
// Display the explosion radius when selected
Gizmos.color = new Color(1, 1, 0, 0.75F);
Gizmos.DrawSphere(transform.position, explosionRadius);
}
}
静态方法
函数名 | 解释 |
---|---|
DrawCube | 绘制实心框. Draw a solid box with center and size. |
DrawFrustum | 绘制摄影机视锥体小控件. Draw a camera frustum using the currently set Gizmos.matrix for it’s location and rotation. |
DrawGUITexture | 绘制纹理 .Draw a texture in the Scene. |
DrawIcon | 绘制小图标.Draw an icon at a position in the Scene view. |
DrawLine | Draws a line starting at from towards to. |
DrawMesh | Draws a mesh. |
DrawRay | Draws a ray starting at from to from + direction. |
DrawSphere | 球.Draws a solid sphere with center and radius. |
DrawWireCube | 立方体.Draw a wireframe box with center and size. |
DrawWireMesh | 空心网格.Draws a wireframe mesh. |
DrawWireSphere | 空心球. Draws a wireframe sphere with center and radius. |
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。