Answers for "unity mesh"

C#
1

unity mesh

using UnityEngine;
using UnityEditor;

public class mesh
{
  void Start()
  {
    Mesh m = new Mesh();
    m.verticies = new Vector3[]//for each polygon you have to make a new verticie
    {
      new Vector3(0, 0, 0),
      new Vector3(1, 0, 0),
      new Vector3(1, 0, 1),
      
      new Vector3(1, 1, 1),
      new Vector3(1, 0, 0),
      new Vector3(1, 0, 1)
    };
    m.triangles = new int[]{0, 1, 2, 3, 5, 4};
    m.RecalculateNormals();
    transform.GetComponent<MeshRenderer>().mesh = m;
  }
}
Posted by: Guest on February-26-2021

C# Answers by Framework

Browse Popular Code Answers by Language