当前位置:   article > 正文

unity 改变颜色透明通道实现闪烁效果 Unity闪烁效果_unity 透明通道 变点点

unity 透明通道 变点点
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class RedLightFlash : MonoBehaviour
{
	private HighlightPlus.HighlightEffect highEffect;

	public float Duration = 1;
	Color colora;
	float value = 0;
	bool isUp = false;
	bool isDown = false;


	// Start is called before the first frame update
	void Start()
    {
		highEffect = this.GetComponent<HighlightPlus.HighlightEffect>();
		if (highEffect != null)
		{
			colora = highEffect.outlineColor;
			value = colora.a;
		}
	}

	// Update is called once per frame
	void Update()
	{
		if (highEffect == null) return;
		
		float speed = 1 / Duration;

		if (value >= 1)
		{
			isUp = false; isDown = true;
		}
		if (value <= 0)
		{
			isUp = true; isDown = false;
		}

		if (isUp)
			value += Time.deltaTime * speed;
		if (isDown)
			value -= Time.deltaTime * speed;

		highEffect.outlineColor = new Color(colora.r, colora.g, colora.b, value);
	}
}

  • 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
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32
  • 33
  • 34
  • 35
  • 36
  • 37
  • 38
  • 39
  • 40
  • 41
  • 42
  • 43
  • 44
  • 45
  • 46
  • 47
  • 48
  • 49
  • 50
  • 51
声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/你好赵伟/article/detail/110129
推荐阅读
相关标签
  

闽ICP备14008679号