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