I’ve tried this but I don’t know what to do after writing the actual code and assigning it to the gameobject I want to fade out.
using UnityEngine;
using System.Collections;
public class fader : MonoBehaviour {
private Color thisColor;
public bool destroyOnFaded=true;
private bool isFading = false;
private Color col = new Color();
// Use this for initialization
void Start () {
thisColor = renderer.material.GetColor("_Color");
col.r = thisColor.r;
col.g = thisColor.g;
col.b = thisColor.b;
col.a = thisColor.a;
isFading = true;
}
// Update is called once per frame
void Update () {
if(isFading){
col.a=-0.99f;//-= 0.5f * (float)Time.deltaTime;
renderer.material.SetColor("_Color", col);
}
}
}