diff --git a/ChromeEnigma/Assets/ColorSubscriber.cs b/ChromeEnigma/Assets/ColorSubscriber.cs index a72c34dc6b4ee16dc140aa0f13c15102c5401693..aa81e1602ee27ceaaf951292328f8e9c8a8c7537 100644 --- a/ChromeEnigma/Assets/ColorSubscriber.cs +++ b/ChromeEnigma/Assets/ColorSubscriber.cs @@ -23,11 +23,16 @@ public class ColorSubscriber : MonoBehaviour public void notifyColorChange(Color c) { - if(c == material.color) + if (c.r == material.color.r && c.g == material.color.g && c.b == material.color.b) { Debug.Log("Subscriber got notified: " + c); mCollider.enabled = true; + material.color = new Color(c.r, c.g, c.b); + } + else + { + mCollider.enabled = false; + material.color = new Color(material.color.r, material.color.g, material.color.b, 0.1f); } - else mCollider.enabled = false; } } diff --git a/ChromeEnigma/Assets/Scripts/ColorChanger.cs b/ChromeEnigma/Assets/Scripts/ColorChanger.cs index d6f6d4f947dac319b4b7293c87bb92f730aec2c6..2108e560ae987494f35112e1b40d07fe9aeaf174 100644 --- a/ChromeEnigma/Assets/Scripts/ColorChanger.cs +++ b/ChromeEnigma/Assets/Scripts/ColorChanger.cs @@ -18,6 +18,10 @@ public class ColorChanger : MonoBehaviour material = userrenderer.material; if (groundColored == null) groundColored = GameObject.FindGameObjectsWithTag("GroundColored"); + foreach (GameObject g in groundColored) + { + if (g != null) g.GetComponent<ColorSubscriber>().notifyColorChange(material.color); + } } // Update is called once per frame @@ -28,8 +32,7 @@ public class ColorChanger : MonoBehaviour material.color = Color.red; foreach (GameObject g in groundColored) { - if (g != null) g.GetComponent<ColorSubscriber>().notifyColorChange(Color.red); - } + if (g != null) g.GetComponent<ColorSubscriber>().notifyColorChange(Color.red); } } if (Input.GetButtonDown(KeyCode.Alpha2.ToString())) {