Skip to content

Commit

Permalink
Merge pull request #6 from prefrontalcortex/feat-urp-hdrp
Browse files Browse the repository at this point in the history
Feat: Use correct default materials on URP/HDRP
  • Loading branch information
keijiro authored May 3, 2022
2 parents 361b556 + f2df475 commit 6ba4624
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions Packages/jp.keijiro.metamesh/Editor/MetameshImporter.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using UnityEngine;
using UnityEditor;
using UnityEngine.Rendering;
#if UNITY_2020_2_OR_NEWER
using UnityEditor.AssetImporters;
#else
Expand Down Expand Up @@ -33,9 +34,11 @@ public override void OnImportAsset(AssetImportContext context)
var meshFilter = gameObject.AddComponent<MeshFilter>();
meshFilter.sharedMesh = mesh;

var pipelineAsset = GraphicsSettings.currentRenderPipeline;
var baseMaterial = pipelineAsset ? pipelineAsset.defaultMaterial : AssetDatabase.GetBuiltinExtraResource<Material>("Default-Diffuse.mat");

var meshRenderer = gameObject.AddComponent<MeshRenderer>();
meshRenderer.sharedMaterial =
AssetDatabase.GetBuiltinExtraResource<Material>("Default-Diffuse.mat");
meshRenderer.sharedMaterial = baseMaterial;

context.AddObjectToAsset("prefab", gameObject);
if (mesh != null) context.AddObjectToAsset("mesh", mesh);
Expand Down

0 comments on commit 6ba4624

Please sign in to comment.