CUI_PerlinNoisePosition.cs 753 B

12345678910111213141516171819202122232425262728
  1. using UnityEngine;
  2. using System.Collections;
  3. namespace CurvedUI
  4. {
  5. public class CUI_PerlinNoisePosition : MonoBehaviour
  6. {
  7. public float samplingSpeed = 1;
  8. public Vector2 Range;
  9. RectTransform rectie;
  10. // Use this for initialization
  11. void Start()
  12. {
  13. rectie = transform as RectTransform;
  14. }
  15. // Update is called once per frame
  16. void Update()
  17. {
  18. rectie.anchoredPosition = new Vector2(Mathf.PerlinNoise(Time.time * samplingSpeed, Time.time * samplingSpeed).Remap(0, 1, -Range.x, Range.x),
  19. Mathf.PerlinNoise(Time.time * samplingSpeed * 1.333f, Time.time * samplingSpeed * 0.888f).Remap(0, 1, -Range.y, Range.y));
  20. }
  21. }
  22. }