revival/game/Assets/Scripts/Rendering/GlitchInit.cs

22 lines
588 B
C#

using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using Random = UnityEngine.Random;
[ExecuteAlways]
public class GlitchInit : MonoBehaviour
{
private void OnEnable()
{
foreach (var glitchRenderer in GetComponentsInChildren<Renderer>())
{
var mpb = new MaterialPropertyBlock();
mpb.SetVector(
"_Positions",
new Vector4(Random.value,Random.value,Random.value,Random.value));
glitchRenderer.SetPropertyBlock(mpb);
}
}
}