using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class NewBehaviourScript : MonoBehaviour
{
public Vector3[] positions;
public int[] triangles1;
public int[] triangles2;
public int[] triangles3;
public Material[] materials;
private Mesh mesh;
private GameObject go;
void Start()
{
mesh = new Mesh();
mesh.name = "123";
mesh.vertices = positions;
go = new GameObject();
MeshFilter mf = go.AddComponent<MeshFilter>();
mf.mesh = mesh;
MeshRenderer mr = go.AddComponent<MeshRenderer>();
mesh.subMeshCount = 3;
mr.materials = materials;
}
void Update()
{
if(Input.GetKeyDown(KeyCode.A))
{
mesh.SetTriangles(triangles1, 0);
}
if (Input.GetKeyDown(KeyCode.B))
{
mesh.SetTriangles(triangles2, 1);
}
if (Input.GetKeyDown(KeyCode.C))
{
mesh.SetTriangles(triangles3, 2);
}
}
}
unity的mesh和submesh
最新推荐文章于 2023-08-22 17:21:29 发布