1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
 
public class colorPulse : MonoBehaviour {
 
    private Material mat;
    public Color colourEnd;
    public Color colourStart;
    private float i;
    private float randomTime;
 
void Start()
{
    colourEnd = Color.black;
    colourStart = Color.red;
    mat = GetComponent<Renderer>().material;
}
void Update()
{
    randomTime = Random.Range(2.0f, 5.0f);
    i += Time.deltaTime;
    mat.SetColor("_EmissionColor", Color.Lerp(colourStart, colourEnd, Mathf.PingPong(i * 2, randomTime)));
}
}
cs


Posted by 도이(doi)
,