how to change the color of an object in unity code example
Example 1: unity change text color
// To change the color of a text, see below
GameObject.GetComponent<Text>().color = Color.black;
Example 2: unity c# change color of gameobject
using UnityEngine;
using System.Collections;
public class collisionpill : MonoBehaviour
{
public Color mycolor;
void OnCollisionEnter(Collision other)
{
if (other.transform.tag == "Pill")
{
gameObject.GetComponent<Renderer>().material.color = mycolor;
}
}
}