how to change unity game background color code example
Example 1: how to change image color unity
using UnityEngine.UI;
public GameObject YourgameObjectWithImage;
YourgameObjectWithImage.GetComponent<Image>().color = new Color32(255, 255, 225, 225);
Example 2: camera color unity
using UnityEngine;
using System.Collections;
public class ExampleClass : MonoBehaviour
{
public Color color1 = Color.red;
public Color color2 = Color.blue;
public float duration = 3.0F;
public Camera cam;
void Start()
{
}
void Update()
{
float t = Mathf.PingPong(Time.time, duration) / duration;
cam.backgroundColor = Color.Lerp(color1, color2, t);
}
}
Example 3: how to change the color of an object in unity c# rgb
void Update ()
{
if(Input.GetKeyDown(KeyCode.R))
{
gameObject.GetComponent<Renderer>().material.color = new Color(233, 79, 55);
}
}
Example 4: unity background camera change
using UnityEngine;
using System.Collections;
public class Myclass: MonoBehaviour
{
public Color Red = Color.red;
public Camera cam;
void Start()
{
}
void Update()
{
cam.backgroundColor = Red;
}
}