From 0927ff6379e81ad0c654b64f9c51daa14956101b Mon Sep 17 00:00:00 2001 From: shenjianxing <”315615051@qq.com“> Date: Mon, 14 Apr 2025 09:59:18 +0800 Subject: [PATCH] =?UTF-8?q?=E9=AB=98=E4=BA=AE=E6=97=B6=E5=B1=8F=E8=94=BD?= =?UTF-8?q?=E8=B4=B4=E5=9B=BE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Assets/Scripts/Item/ObjectColorToggle.cs | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/Assets/Scripts/Item/ObjectColorToggle.cs b/Assets/Scripts/Item/ObjectColorToggle.cs index 758ba9a0..350f0501 100644 --- a/Assets/Scripts/Item/ObjectColorToggle.cs +++ b/Assets/Scripts/Item/ObjectColorToggle.cs @@ -12,8 +12,9 @@ public class ObjectColorToggle : MonoBehaviour } public Color isOnColor = new Color(86 / 255f, 255 / 255f, 160 / 255f); public Color isOffColor = new Color(255 / 255f, 255 / 255f, 255 / 255f); - public Color isHoverColor = new Color(185f / 255f, 255 / 255f, 215/ 255f); + public Color isHoverColor = new Color(185f / 255f, 255 / 255f, 215 / 255f); MeshRenderer mesh; + private Texture2D savedTexture; private void Awake() { mesh = gameObject.GetComponent(); @@ -26,14 +27,19 @@ public class ObjectColorToggle : MonoBehaviour { case State.On: isOnColor.a = alpha; + savedTexture = mesh.material.mainTexture as Texture2D; + mesh.material.mainTexture = null; mesh.material.color = isOnColor; break; case State.Off: isOffColor.a = alpha; + mesh.material.mainTexture = savedTexture; mesh.material.color = isOffColor; break; case State.Hover: isHoverColor.a = alpha; + savedTexture = mesh.material.mainTexture as Texture2D; + mesh.material.mainTexture = null; mesh.material.color = isHoverColor; break; default: @@ -56,5 +62,4 @@ public class ObjectColorToggle : MonoBehaviour SetColor(State.Off); } } - -} +} \ No newline at end of file