organize scripts
This commit is contained in:
@@ -0,0 +1,30 @@
|
||||
using UnityEngine;
|
||||
|
||||
// Very simple script, just takes a light on start and slowly fades it to 0
|
||||
// over the duration specified.
|
||||
[RequireComponent(typeof(Light))]
|
||||
public class FadingLight : MonoBehaviour
|
||||
{
|
||||
|
||||
Light lightObj;
|
||||
|
||||
public float duration;
|
||||
public bool isFading;
|
||||
|
||||
float timer;
|
||||
float startIntensity;
|
||||
|
||||
void Start()
|
||||
{
|
||||
lightObj = GetComponent<Light>();
|
||||
startIntensity = lightObj.intensity;
|
||||
}
|
||||
|
||||
void Update()
|
||||
{
|
||||
timer += Time.deltaTime;
|
||||
float t = timer / duration;
|
||||
t = Mathf.Clamp01(t);
|
||||
lightObj.intensity = Mathf.Lerp(startIntensity, 0, t);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user