You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
37 lines
819 B
37 lines
819 B
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
|
|
public class FaGuangItem : MonoBehaviour
|
|
{
|
|
private Material material;
|
|
private float value;
|
|
private float speed = 5f;
|
|
private Color color;
|
|
// Start is called before the first frame update
|
|
void Start()
|
|
{
|
|
material = this.GetComponent<MeshRenderer>().material;
|
|
color = material.color;
|
|
}
|
|
|
|
// Update is called once per frame
|
|
void Update()
|
|
{
|
|
value += speed * Time.deltaTime;
|
|
if (value >= 1)
|
|
{
|
|
speed = -2;
|
|
}
|
|
|
|
if (value <=0 )
|
|
{
|
|
speed = 2;
|
|
}
|
|
|
|
float factor = Mathf.Pow(2, value);
|
|
material.SetColor("_EmissionColor", new Color(color.r * factor, color.g * factor, color.b * factor));
|
|
|
|
}
|
|
}
|