CachedLightProperties.cs 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. #if UNITY_EDITOR
  2. using UnityEngine;
  3. namespace VLB
  4. {
  5. struct CachedLightProperties
  6. {
  7. Light light;
  8. float range;
  9. float spotAngle;
  10. Color color;
  11. public CachedLightProperties(Light lightParam)
  12. {
  13. light = lightParam;
  14. range = -1f;
  15. spotAngle = -1f;
  16. color = Color.white;
  17. if (light && light.type == LightType.Spot)
  18. {
  19. range = light.range;
  20. spotAngle = light.spotAngle;
  21. color = light.color;
  22. }
  23. }
  24. public override int GetHashCode() { return light ? light.GetHashCode() : 0; }
  25. public bool Equals(CachedLightProperties other) { return Equals(other, this); }
  26. public override bool Equals(object obj)
  27. {
  28. if (obj == null || GetType() != obj.GetType())
  29. return false;
  30. var other = (CachedLightProperties)obj;
  31. return other.range == range && other.spotAngle == spotAngle && other.color == color;
  32. }
  33. }
  34. }
  35. #endif