MaterialToCombine.cs 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. using UnityEngine;
  2. using System.Collections;
  3. namespace LunarCatsStudio.SuperCombiner
  4. {
  5. /// <summary>
  6. /// Class storing data of a single _material to combine
  7. /// </summary>
  8. public class MaterialToCombine
  9. {
  10. /// <summary>
  11. /// The _material to combine
  12. /// </summary>
  13. public Material _material;
  14. /// <summary>
  15. /// The maximum uv bounds for this _material
  16. /// </summary>
  17. public Rect _uvBounds;
  18. /// <summary>
  19. /// The _index of the combined _material
  20. /// </summary>
  21. public int _combinedIndex;
  22. /// <summary>
  23. /// Index of this element in it's list. This _index is equal to the combinedIdex
  24. /// </summary>
  25. public int _index;
  26. /// <summary>
  27. /// This is the mesh having the biggest UV bounds
  28. /// </summary>
  29. public Mesh _meshHavingBiggestUVBounds;
  30. /// <summary>
  31. /// Get the scaled and offseted by _material parameters uv bounds
  32. /// </summary>
  33. /// <returns></returns>
  34. public Rect GetScaledAndOffsetedUVBounds()
  35. {
  36. Rect rect = _uvBounds;
  37. if (_material.HasProperty("_MainTex"))
  38. {
  39. rect.size = Vector2.Scale(rect.size, _material.mainTextureScale);
  40. rect.position += _material.mainTextureOffset;
  41. }
  42. return rect;
  43. }
  44. }
  45. }