Unity modify the particle Render Material (23rd of Unity3D development), and the particle sunity3d

Source: Internet
Author: User

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.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.