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

22 lines
588 B
C#
Raw Normal View History

2021-04-25 01:59:37 +02:00
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using Random = UnityEngine.Random;
2021-04-25 06:16:35 +02:00
[ExecuteAlways]
2021-04-25 01:59:37 +02:00
public class GlitchInit : MonoBehaviour
{
private void OnEnable()
{
2021-04-25 06:16:35 +02:00
foreach (var glitchRenderer in GetComponentsInChildren<Renderer>())
2021-04-25 01:59:37 +02:00
{
var mpb = new MaterialPropertyBlock();
mpb.SetVector(
"_Positions",
new Vector4(Random.value,Random.value,Random.value,Random.value));
glitchRenderer.SetPropertyBlock(mpb);
}
}
}