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 |
'programming > c#' 카테고리의 다른 글
유니티 textureOffset (0) | 2020.02.19 |
---|---|
유니티 line renderer로 그리드 생성 (0) | 2020.02.15 |
유니티 객체 생성하기 (Instantiate) (0) | 2020.02.02 |
유니티 Physics - 움직임의 jitter를 줄이는 방법 (0) | 2020.01.04 |
GPU Instancing 최적화! 최적화! (1) | 2020.01.01 |