37 lines
989 B
C#
37 lines
989 B
C#
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
|
|
public class FadeController : MonoBehaviour
|
|
{
|
|
public Material[] selfMaters;
|
|
public bool isFade = false;
|
|
public float speed = 1;
|
|
void Update()
|
|
{
|
|
if (isFade)
|
|
{
|
|
if (selfMaters != null)
|
|
{
|
|
for (int i = 0; i < selfMaters.Length; i++)
|
|
{
|
|
float current_Opacity = selfMaters[i].GetFloat("_Opacity");
|
|
float t = Mathf.Lerp(current_Opacity, 1, Time.deltaTime * speed);
|
|
Debug.Log("Surface_mat_opacity==" + t);
|
|
if (t > 0.9f)
|
|
{
|
|
t = 1;
|
|
}
|
|
selfMaters[i].SetFloat("_Opacity", t);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
public void OnFadeUnFade(bool _isFade)
|
|
{
|
|
isFade = _isFade;
|
|
selfMaters = GetComponent<MeshRenderer>().materials;
|
|
}
|
|
}
|