Skip to content

Commit

Permalink
use instantiate instead of constructor to make new material
Browse files Browse the repository at this point in the history
hopefully help with #17? idk why these would behave differently but clearly Unity has a bug here
  • Loading branch information
drewcassidy committed Oct 22, 2024
1 parent 6a9f79f commit 4d1b349
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion Source/MaterialDef.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand Down Expand Up @@ -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 };
Expand Down

0 comments on commit 4d1b349

Please sign in to comment.