Skip to content
Snippets Groups Projects
Commit 6846c8fd authored by William G. Tresselt's avatar William G. Tresselt
Browse files

Fixed more bugs related to colors and made it more apparent which is activated

parent 42a8a004
No related branches found
No related tags found
No related merge requests found
......@@ -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;
}
}
......@@ -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()))
{
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment