protected void GenerateMesh() { if (!railMesh && !tieMesh) { generatedMesh.Clear(); return; } Profiler.BeginSample("Track.GenerateMesh", this); #if UNITY_EDITOR if (gameObject.isStatic && Application.isPlaying && !isStartup) { Debug.LogWarning("Trying to update a mesh on a track marked as static", this); } #endif if (meshGenerator == null) { meshGenerator = new TrackMeshGenerator(); } meshGenerator.SetMeshes(railMesh, tieMesh); meshGenerator.GenerateMesh(generatedMesh, this); #if UNITY_EDITOR if (gameObject.isStatic) { Unwrapping.GenerateSecondaryUVSet(generatedMesh); } #endif meshGenerator.GenerateMesh(generatedMesh, this); Profiler.EndSample(); }
/** * If you dynamically swap out the meshes used to generate this track call this to make sure * the mesh gets regenerated correctly. */ public void ResetMeshGenerator() { Dirty = true; meshGenerator = null; }