Unity modify the particle Render Material (23rd of Unity3D development), and the particle sunity3d
Monkey original, reprinted. Reprinted Please note: Reprinted from the Cocos2Der-CSDN, thank you!
Address: http://blog.csdn.net/cocos2der/article/details/48372999
Art needs to be able to modify the particle effect when making the particle effect, so that the particle will flash at some time. After reading it, I found that no settings can be implemented, so I added a script for the art.
The principle is to enable the art to control the Render to modify the Image Color.
Using UnityEngine; using System. collections; public class maid: MonoBehaviour {public float startBlinkTime = 0.0f; public float blinkFrameTime = 0.02f; public Color [] blinkColor = new Color [] {new Color (255.0f, 255.0f, 255.0f, 255.0f, 0.0f), new Color (255.0f, 255.0f, 255.0f, 255.0f)}; private Material m_Material; private float m_BlinkLifeTime = 0.0f; private bool m_IsStartBlink = false; private int m_BlinkColorIndex = 0; // Use this for initialization void Start () {m_Material = GetComponent <Renderer> (). material; m_BlinkLifeTime = 0; if (startBlinkTime> 0) {m_IsStartBlink = false; Invoke ("StartBlink", startBlinkTime);} else {m_IsStartBlink = true ;}} // Update is called once per frame void Update () {if (m_IsStartBlink) {UpdateColor () ;}} void UpdateColor () {if (blinkColor = null | blinkColor. length <= 0) {return;} m_BlinkLifeTime + = Time. deltaTime; if (m_BlinkLifeTime> = blinkFrameTime) {m_BlinkLifeTime = 0; // Render Material uses different Shader. Here, the Color variable name must be changed to m_Material.SetColor ("_ Color ", blinkColor [m_BlinkColorIndex]); m_BlinkColorIndex + = 1; if (m_BlinkColorIndex> = blinkColor. length) {m_BlinkColorIndex = 0 ;}} void StartBlink () {m_IsStartBlink = true ;}}
Copyright Disclaimer: This article is an original article by the blogger and cannot be reproduced without the permission of the blogger.