diff --git a/Packages/jp.keijiro.metamesh/Editor/MetameshImporter.cs b/Packages/jp.keijiro.metamesh/Editor/MetameshImporter.cs index c83c811..a8fc3a1 100644 --- a/Packages/jp.keijiro.metamesh/Editor/MetameshImporter.cs +++ b/Packages/jp.keijiro.metamesh/Editor/MetameshImporter.cs @@ -1,5 +1,6 @@ using UnityEngine; using UnityEditor; +using UnityEngine.Rendering; #if UNITY_2020_2_OR_NEWER using UnityEditor.AssetImporters; #else @@ -33,9 +34,11 @@ public override void OnImportAsset(AssetImportContext context) var meshFilter = gameObject.AddComponent(); meshFilter.sharedMesh = mesh; + var pipelineAsset = GraphicsSettings.currentRenderPipeline; + var baseMaterial = pipelineAsset ? pipelineAsset.defaultMaterial : AssetDatabase.GetBuiltinExtraResource("Default-Diffuse.mat"); + var meshRenderer = gameObject.AddComponent(); - meshRenderer.sharedMaterial = - AssetDatabase.GetBuiltinExtraResource("Default-Diffuse.mat"); + meshRenderer.sharedMaterial = baseMaterial; context.AddObjectToAsset("prefab", gameObject); if (mesh != null) context.AddObjectToAsset("mesh", mesh);