Init
This commit is contained in:
33
Assets/ThirdParty/DestroyIt/Demos (safe to delete)/Scripts/Effects/FlareFadeOut.cs
vendored
Normal file
33
Assets/ThirdParty/DestroyIt/Demos (safe to delete)/Scripts/Effects/FlareFadeOut.cs
vendored
Normal file
@@ -0,0 +1,33 @@
|
||||
using UnityEngine;
|
||||
|
||||
namespace DestroyIt
|
||||
{
|
||||
public class FlareFadeOut : MonoBehaviour
|
||||
{
|
||||
|
||||
[Range(0f, 10f)]
|
||||
public float flareFadeSeconds = 5f;
|
||||
|
||||
private float startBrightness;
|
||||
private LensFlare flare;
|
||||
|
||||
// Use this for initialization
|
||||
void Start()
|
||||
{
|
||||
flare = GetComponent<LensFlare>();
|
||||
startBrightness = flare.brightness;
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
void Update()
|
||||
{
|
||||
flare.brightness -= Mathf.Clamp01(Time.deltaTime / (flareFadeSeconds / startBrightness));
|
||||
|
||||
if (flare.brightness <= 0f)
|
||||
{
|
||||
Destroy(flare);
|
||||
Destroy(this);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user