BaseStarDataRenderer.cs 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. // Base class for data star rendering implementations.
  5. public abstract class BaseStarDataRenderer : System.Object {
  6. public delegate void StarDataProgress(BaseStarDataRenderer renderer, float progress);
  7. public delegate void StarDataComplete(BaseStarDataRenderer renderer, Texture2D texture, bool success);
  8. public event StarDataProgress progressCallback;
  9. public event StarDataComplete completionCallback;
  10. public float density;
  11. public float imageSize;
  12. public string layerId;
  13. public float maxRadius;
  14. protected float sphereRadius = 1.0f;
  15. protected bool isCancelled;
  16. // This is a coroutine so we don't block the main editor thread.
  17. public abstract IEnumerator ComputeStarData();
  18. public virtual void Cancel()
  19. {
  20. progressCallback = null;
  21. completionCallback = null;
  22. }
  23. protected void SendProgress(float progress)
  24. {
  25. if (progressCallback != null) {
  26. progressCallback(this, progress);
  27. }
  28. }
  29. protected void SendCompletion(Texture2D texture, bool success)
  30. {
  31. if (completionCallback != null) {
  32. completionCallback(this, texture, success);
  33. }
  34. }
  35. }