最近在研究unity粒子特效,找到了个不错的特效。
实现效果如下
使用的插件在官方商店就有,免费的《MK Glow Free》
拿图片效果做示例
首先导入其资源包,然后新建一空物体,添加两个组件“Sprite Renderer”和“Rotate Object”。前者是添加图片,后者是控制图片动起来。
当然你添加完之后shader会是默认的,所以你需要兴建一个marterail,然后将marterail的shader设置为插件中的shader
然后控制其光亮闪动,根据例子可以得出其控制光亮的熟悉在 MKGlow脚本下的Threshold熟悉,你需要给你的主相机添加两个脚本,MKGlow和ChangeSettingLegacy。
随后添加一个脚本控制Threshold属性
代码如下
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using MK.Glow.Example;
public class Blink : MonoBehaviour
{
public GameObject obj;
private bool IsAdd = true;
public ChangeSettingsLegacy set;
public float speed = 0.02f;
// Start is called before the first frame update
void Start()
{
obj = this.gameObject;
set = obj.GetComponent<ChangeSettingsLegacy>();
set.bloomThreshold = 1.5f;
}
// Update is called once per frame
void Update()
{
LightBlink();
}
void LightBlink(){
float index = set.bloomThreshold;
if (!IsAdd)
{
set.bloomThreshold -= speed;
if (index < 0.9f)
{
IsAdd = true;
}
}
else {
set.bloomThreshold += speed;
if (index >1.5f)
{
IsAdd = false;
}
}
}
}
搞定