Good Afternoon, I have been trying to build a mesh in edit mode.
Using MeshFilter.mesh in editor gives error
Instantiating mesh due to calling MeshFilter.mesh during edit mode. This will leak meshes
It recommends using MeshFilter.SharedMesh, I cannot use this as i want each mesh to be a separate object that can be manipulated.
Thanks Again for all your help.
Current Code
using UnityEngine;
using UnityEditor;
using System.Collections;
[ExecuteInEditMode]
[RequireComponent (typeof (MeshFilter))]
public class Generate : MonoBehaviour {
private Mesh s;
private Vector3[] vertices = {
new Vector2(0,0),
new Vector2(0,1),
new Vector2(1,1),
new Vector2(1,0)
};
private int[] triangles = {
0,1,2,
2,3,0
};
public void Create()
{
MeshFilter meshfilter = gameObject.GetComponent<MeshFilter>();
s = meshfilter.mesh; //Error Line//
s.name = "S";
s.vertices = vertices;
s.triangles = triangles;
}
}