From 4d1b34919c904922e9ed7deb5c705153f3281feb Mon Sep 17 00:00:00 2001 From: Andrew Cassidy Date: Mon, 21 Oct 2024 23:47:44 -0700 Subject: [PATCH] use instantiate instead of constructor to make new material hopefully help with #17? idk why these would behave differently but clearly Unity has a bug here --- Source/MaterialDef.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Source/MaterialDef.cs b/Source/MaterialDef.cs index fa0360e..9ef480e 100644 --- a/Source/MaterialDef.cs +++ b/Source/MaterialDef.cs @@ -21,6 +21,7 @@ You should have received a copy of the GNU General Public License using System.Runtime.CompilerServices; using HarmonyLib; using UnityEngine; +using Object = UnityEngine.Object; namespace Shabby { @@ -147,7 +148,7 @@ public Material Instantiate(Material referenceMaterial) Material material; if (updateExisting) { - material = new Material(referenceMaterial); + material = Object.Instantiate(referenceMaterial); if (shader != null) material.shader = shader; } else { material = new Material(shader) { name = referenceMaterial.name };