wip : lighting theater

This commit is contained in:
Ferlat Thibaud
2026-06-09 14:40:32 +02:00
parent f77b717afc
commit 53c07af7a7
15 changed files with 5067 additions and 1404 deletions
@@ -0,0 +1,35 @@
#if UNITY_EDITOR
using UnityEditor;
using UnityEngine;
public class ReplacWithPrefab : EditorWindow
{
GameObject prefab;
string nameFilter = "spotlight_A";
[MenuItem("Tools/Replace With Prefab")]
static void Open() => GetWindow<ReplacWithPrefab>();
void OnGUI()
{
prefab = (GameObject)EditorGUILayout.ObjectField("Prefab", prefab, typeof(GameObject), false);
nameFilter = EditorGUILayout.TextField("Name filter", nameFilter);
if (GUILayout.Button("Replace") && prefab)
{
var all = FindObjectsByType<GameObject>(FindObjectsSortMode.None);
foreach (var go in all)
{
if (!go.name.StartsWith(nameFilter)) continue;
var instance = (GameObject)PrefabUtility.InstantiatePrefab(prefab, go.transform.parent);
instance.transform.SetPositionAndRotation(go.transform.position, go.transform.rotation);
instance.transform.localScale = go.transform.localScale;
instance.name = go.name;
Undo.RegisterCreatedObjectUndo(instance, "Replace");
Undo.DestroyObjectImmediate(go);
}
}
}
}
#endif
@@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: 59c4a4cbd97f25a4db75c5062141bb84
@@ -19,7 +19,10 @@ namespace Unheimlich.VFX
private float _randomOffset;
void Start()
[Header("Glitch Object")]
public GameObject glitchObject;
void OnEnable()
{
_randomOffset = Random.Range(0f, 1000f);
StartCoroutine(FlickerRoutine());
@@ -32,27 +35,38 @@ namespace Unheimlich.VFX
{
while (true)
{
float t = Mathf.PerlinNoise(Time.time * flickerSpeed + _randomOffset, 0f);
ApplyFlicker(t);
if (flickerSpeed > 0f)
{
float t = Mathf.PerlinNoise(Time.time * flickerSpeed + _randomOffset, 0f);
ApplyFlicker(t);
}
else
{
if (targetLight) targetLight.intensity = 0f;
}
if (Random.value < glitchChance)
if (Random.value < glitchChance * Time.deltaTime)
yield return StartCoroutine(GlitchBurst());
yield return null;
}
}
private IEnumerator GlitchBurst()
{
float elapsed = 0f;
float duration = Random.Range(glitchMinDuration, glitchMaxDuration);
if (glitchObject) glitchObject.SetActive(true);
while (elapsed < duration)
{
ApplyFlicker(Random.value);
elapsed += Time.deltaTime;
yield return null;
}
if (glitchObject) glitchObject.SetActive(false);
if (targetLight) targetLight.intensity = 0f;
}
private void ApplyFlicker(float t)