如果想在unity中显示图形,那么就需要MeshFilter(网格过滤器)和MeshRender(网格渲染器),二者缺一不可。在Unity中所有能看见的图像都是基于此生成的。在unity中绘制一个图形的前提是确认顶点位置,制定绘制顺序,这样才能看见对应的图像,unity中才有三角形绘制完整图像,所以一个图像会由若干个三角形组成。
三个顶点的渲染顺序决定了面的正反,正面可以触发碰撞等,反面则没有这种效果
三个点的顺序为顺时针就是正面,逆时针就是反面
一、画cube

通过上方的介绍我们知道,cube正方体的组成就是六个面的绘制,包括八个顶点
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class CreateMesh : MonoBehaviour
{
// Start is called before the first frame update
void Start()
{
Mesh mesh=new Mesh();
// //添加网格过滤器,网格渲染器,网格碰撞器。刚体
gameObject.AddComponent<MeshFilter>();
gameObject.AddComponent<MeshRenderer>();
gameObject.AddComponent<MeshCollider>();
gameObject.AddComponent<Rigidbody>();
VertexHelper vh = n

最低0.47元/天 解锁文章
1563

被折叠的 条评论
为什么被折叠?



