My code below is modeled after Unity's documentation. When I put the script into an empty GameObject, the error I get is:
MissingComponentException: There is no 'MeshFilter' attached to the "myMesh" game object, but a script is trying to access it.
How do I add a MeshFilter (and the other necessary Components) to the empty GameObject in order to generate the model procedurally?
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class myMesh : MonoBehaviour {
public Mesh mesh;
void Start(){
mesh= new Mesh();
GetComponent<MeshFilter>().mesh = mesh;
}
}