// Uncomment this line to enable this script. // #define PROBUILDER_API_EXAMPLE using UnityEngine; using UnityEditor; using UnityEditor.ProBuilder; using UnityEngine.ProBuilder; namespace ProBuilder.EditorExamples { /// /// This script demonstrates one use case for the pb_EditorUtility.onMeshCompiled delegate. /// Whenever ProBuilder compiles a mesh it removes the colors, tangents, and uv attributes. /// [InitializeOnLoad] sealed class ClearUnusedAttributes : Editor { /// /// Static constructor is called and subscribes to the OnMeshCompiled delegate. /// static ClearUnusedAttributes() { EditorMeshUtility.meshOptimized += OnMeshCompiled; } /// /// When a ProBuilder object is compiled to UnityEngine.Mesh this is called. /// /// /// static void OnMeshCompiled(ProBuilderMesh probuilderMesh, Mesh mesh) { #if PROBUILDER_API_EXAMPLE mesh.uv = null; mesh.colors32 = null; mesh.tangents = null; #endif } } }