static void SaveMesh(IProceduralMesh aMesh) { aMesh.Build(true); Mesh m = aMesh.MeshData; string name = ""; string file = ""; GetUniquePath((aMesh as Component).gameObject, m.name, out name, out file); try { UnityEditor.AssetDatabase.CreateAsset(m, file); UnityEditor.AssetDatabase.Refresh( ); } catch { Debug.LogError("Unable to save prefab procedural mesh! Likely, you deleted the mesh files, and the prefab is still referencing them. Restarting your Unity editor should solve this minor issue."); } }
static void SaveMesh (IProceduralMesh aMesh) { aMesh.Build(true); Mesh m = aMesh.MeshData; if (m.name.Contains(procMeshPrefix)) { return; } string name = ""; string file = ""; GetUniquePath((aMesh as Component).gameObject, out name, out file); m.name = name; try { UnityEditor.AssetDatabase.CreateAsset(m, file); UnityEditor.AssetDatabase.Refresh ( ); } catch { Debug.LogError("Unable to save prefab procedural mesh! Likely, you deleted the mesh files, and the prefab is still referencing them. Restarting your Unity editor should solve this minor issue."); } }
public static Vertex GetNearestVertex(this IProceduralMesh thisMesh, Vector3 worldPoint) { return(thisMesh.GetVertices().OrderBy(vertex => Vector3.Distance(vertex.AsVector3, worldPoint)).FirstOrDefault()); }
public static IEnumerable <Vertex> GetVertices(this IProceduralMesh thisMesh) { return(thisMesh.TriangleMeshes.SelectMany(triangle => triangle.Vertices)); }
public void AddMesh(IProceduralMesh mesh) { Meshes.Add(mesh); }