unity new colorobject code example
Example 1: 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;
}
}
}
Example 2: new color unity
Color color = new Color(red,green,blue,alpha)//Alpha 0 is transparent