TC_SeedAnimate.cs 957 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. using UnityEngine;
  2. using System.Collections;
  3. namespace TerrainComposer2
  4. {
  5. [ExecuteInEditMode]
  6. public class TC_SeedAnimate : MonoBehaviour
  7. {
  8. public float animateSpeed;
  9. float time;
  10. void Update()
  11. {
  12. MyUpdate();
  13. }
  14. void MyUpdate()
  15. {
  16. if (TC_Settings.instance == null) return;
  17. TC_Settings.instance.seed += (Time.realtimeSinceStartup - time) * animateSpeed;
  18. time = Time.realtimeSinceStartup;
  19. TC.AutoGenerate();
  20. }
  21. #if UNITY_EDITOR
  22. void OnEnable()
  23. {
  24. TC.AutoGenerate();
  25. UnityEditor.EditorApplication.update += MyUpdate;
  26. }
  27. void OnDisable()
  28. {
  29. UnityEditor.EditorApplication.update -= MyUpdate;
  30. }
  31. void OnDestroy()
  32. {
  33. UnityEditor.EditorApplication.update -= MyUpdate;
  34. }
  35. #endif
  36. }
  37. }