From facfe23d7ceeef633c5eb0a955725981d8b7e7cf Mon Sep 17 00:00:00 2001 From: Felix Herbst Date: Mon, 22 Nov 2021 00:00:24 +0100 Subject: [PATCH] feat: toggle to generate lightmap UVs --- Packages/jp.keijiro.metamesh/Editor/MetameshImporter.cs | 2 ++ Packages/jp.keijiro.metamesh/Editor/MetameshImporterEditor.cs | 4 ++++ 2 files changed, 6 insertions(+) diff --git a/Packages/jp.keijiro.metamesh/Editor/MetameshImporter.cs b/Packages/jp.keijiro.metamesh/Editor/MetameshImporter.cs index f2fd925..2135dd7 100644 --- a/Packages/jp.keijiro.metamesh/Editor/MetameshImporter.cs +++ b/Packages/jp.keijiro.metamesh/Editor/MetameshImporter.cs @@ -22,6 +22,7 @@ public sealed class MetameshImporter : ScriptedImporter [SerializeField] RoundedBox _roundedBox = new RoundedBox(); [SerializeField] Ring _ring = new Ring(); [SerializeField] Disc _disc = new Disc(); + [SerializeField] bool _generateLightmapUVs = false; public override void OnImportAsset(AssetImportContext context) { @@ -63,6 +64,7 @@ Mesh ImportAsMesh(string path) } mesh.RecalculateBounds(); + if(_generateLightmapUVs) Unwrapping.GenerateSecondaryUVSet(mesh); mesh.UploadMeshData(true); return mesh; diff --git a/Packages/jp.keijiro.metamesh/Editor/MetameshImporterEditor.cs b/Packages/jp.keijiro.metamesh/Editor/MetameshImporterEditor.cs index 6510f1e..684ae79 100644 --- a/Packages/jp.keijiro.metamesh/Editor/MetameshImporterEditor.cs +++ b/Packages/jp.keijiro.metamesh/Editor/MetameshImporterEditor.cs @@ -20,6 +20,7 @@ sealed class MetameshImporterEditor : ScriptedImporterEditor SerializedProperty _roundedBox; SerializedProperty _ring; SerializedProperty _disc; + SerializedProperty _generateLightmapUVs; public override void OnEnable() { @@ -33,6 +34,7 @@ public override void OnEnable() _roundedBox = serializedObject.FindProperty("_roundedBox"); _ring = serializedObject.FindProperty("_ring"); _disc = serializedObject.FindProperty("_disc"); + _generateLightmapUVs = serializedObject.FindProperty("_generateLightmapUVs"); } public override void OnInspectorGUI() @@ -53,6 +55,8 @@ public override void OnInspectorGUI() case Shape.Disc : EditorGUILayout.PropertyField(_disc); break; } + EditorGUILayout.PropertyField(_generateLightmapUVs); + serializedObject.ApplyModifiedProperties(); ApplyRevertGUI(); }