I would imagine this has a very simple solution but I can’t find It. In my example I click the block on the right to highlight it.
after I release left click the highlight is removed, I want the block on the right to stay highlighted until I click the block on the left like in this example.
Both blocks have the same script attached to them. I use:
private float blueMultiply = 3.50f;
private float redGreenMultiply = 0.50f;
private Color originalColor;
private void Start()
{
originalColor = gameObject.GetComponent<Renderer> ().material.color;
}
void OnMouseDown()
{
AddHighlight();
}
void OnMouseUp()
{
RemoveHighlight();
}
private void AddHighlight()
{
float red = originalColor.r * redGreenMultiply;
float blue = originalColor.b * blueMultiply;
float green = originalColor.g * redGreenMultiply;
gameObject.GetComponent<Renderer> ().material.color = new Color(red, green, blue);
}
private void RemoveHighlight ()
{
gameObject.GetComponent<Renderer> ().material.color = originalColor;
}
How can I remove the highlight only when another gameobject, in this case the other block is clicked. So I don’t have to use onMouseup to remove the highlight