diff options
author | chai <chaifix@163.com> | 2020-12-30 20:59:04 +0800 |
---|---|---|
committer | chai <chaifix@163.com> | 2020-12-30 20:59:04 +0800 |
commit | e9ea621b93fbb58d9edfca8375918791637bbd52 (patch) | |
tree | 19ce3b1c1f2d51eda6878c9d0f2c9edc27f13650 /Client/Assembly-CSharp/MeshRendererExtensions.cs |
+init
Diffstat (limited to 'Client/Assembly-CSharp/MeshRendererExtensions.cs')
-rw-r--r-- | Client/Assembly-CSharp/MeshRendererExtensions.cs | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/Client/Assembly-CSharp/MeshRendererExtensions.cs b/Client/Assembly-CSharp/MeshRendererExtensions.cs new file mode 100644 index 0000000..dddc50d --- /dev/null +++ b/Client/Assembly-CSharp/MeshRendererExtensions.cs @@ -0,0 +1,23 @@ +using System; +using UnityEngine; + +public static class MeshRendererExtensions +{ + public static void SetSprite(this MeshRenderer self, Texture2D spr) + { + if (spr != null) + { + self.SetCutout(spr); + self.material.color = Color.white; + return; + } + self.SetCutout(null); + self.material.color = Color.clear; + } + + public static void SetCutout(this MeshRenderer self, Texture2D txt) + { + self.material.SetTexture("_MainTex", txt); + self.material.SetTexture("_EmissionMap", txt); + } +} |