Skip to content

Commit a0630ff

Browse files
committed
Fix DrawMeshPreview not work in non-URP projects
1 parent 421f94d commit a0630ff

File tree

1 file changed

+14
-2
lines changed

1 file changed

+14
-2
lines changed

Editor.Extras/Drawers/PreviewMeshDrawer.cs

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
using System;
2+
using System.Linq;
23
using TriInspector;
34
using TriInspector.Drawers;
45
using TriInspector.Elements;
@@ -77,8 +78,19 @@ private Material GetMat
7778
{
7879
if (_mat == null)
7980
{
80-
_mat = new Material(Shader.Find("Universal Render Pipeline/Lit"));
81-
_mat.color = new Color(0.4f, 0.7f, 0.4f);
81+
var shaderNames = new[]
82+
{
83+
"Universal Render Pipeline/Lit",
84+
"Standard",
85+
"Legacy Shaders/Diffuse",
86+
};
87+
88+
var shader = shaderNames.Select(name => Shader.Find(name)).First(shader => shader != null);
89+
90+
_mat = new Material(shader)
91+
{
92+
color = new Color(0.4f, 0.7f, 0.4f),
93+
};
8294
}
8395
return _mat;
8496
}

0 commit comments

Comments
 (0)