ShaderParameterSetter.cs 644 B

12345678910111213141516171819202122232425
  1. using UnityEngine;
  2. namespace Assets.Scripts.Materialization
  3. {
  4. internal sealed class ShaderParameterSetter : MonoBehaviour
  5. {
  6. private const string ShaderName = "QFX/SF_VFX/Materialization";
  7. private const string ParameterName = "_Center";
  8. public Vector3 ParameterOffset;
  9. private Renderer _rend;
  10. private void Start()
  11. {
  12. _rend = GetComponent<Renderer>();
  13. _rend.material.shader = Shader.Find(ShaderName);
  14. }
  15. private void Update()
  16. {
  17. _rend.material.SetVector(ParameterName, transform.position + ParameterOffset);
  18. }
  19. }
  20. }