ChangeColor.OnPointerClick C# (CSharp) Method

OnPointerClick() public method

public OnPointerClick ( PointerEventData data ) : void
data PointerEventData
return void
    public void OnPointerClick(PointerEventData data)
    {
        if (GetComponent<Renderer>() != null)
            GetComponent<Renderer>().material.color = new Color(Random.value, Random.value, Random.value, 1.0f);
        else if (GetComponent<Light>() != null)
            GetComponent<Light>().color = new Color(Random.value, Random.value, Random.value, 1.0f);
    }