CircuitTextureScroll.cs 826 B

123456789101112131415161718192021222324252627282930313233
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. public class CircuitTextureScroll : MonoBehaviour {
  5. ParticleSystem ps;
  6. Material particleMaterial;
  7. Vector2 partOffset;
  8. public float partTextureScrollSpeed = -1;
  9. // Use this for initialization
  10. void Start () {
  11. ps = GetComponent<ParticleSystem>();
  12. particleMaterial = ps.GetComponent<Renderer>().material;
  13. partOffset = particleMaterial.mainTextureOffset;
  14. }
  15. // Update is called once per frame
  16. void LateUpdate () {
  17. //Scroll texture according to speed set in the editor
  18. partOffset.y += partTextureScrollSpeed * Time.deltaTime;
  19. if (partOffset.y <= -1)
  20. {
  21. partOffset.y = 0;
  22. }
  23. particleMaterial.mainTextureOffset = partOffset;
  24. }
  25. }