OnlyOneEdgeModifier.cs 1022 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. using UnityEngine;
  2. using System.Collections;
  3. using UnityEngine.UI;
  4. [ModifierID("Only One Edge")]
  5. public class OnlyOneEdgeModifier : ProceduralImageModifier {
  6. [SerializeField]private float radius;
  7. [SerializeField]private ProceduralImageEdge side;
  8. public enum ProceduralImageEdge{
  9. Top,
  10. Bottom,
  11. Left,
  12. Right
  13. }
  14. public float Radius {
  15. get {
  16. return radius;
  17. }
  18. set {
  19. radius = value;
  20. }
  21. }
  22. public ProceduralImageEdge Side {
  23. get {
  24. return side;
  25. }
  26. set {
  27. side = value;
  28. }
  29. }
  30. #region implemented abstract members of ProceduralImageModifier
  31. public override Vector4 CalculateRadius (Rect imageRect){
  32. switch (side) {
  33. case ProceduralImageEdge.Top:
  34. return new Vector4(radius,radius,0,0);
  35. case ProceduralImageEdge.Right:
  36. return new Vector4(0,radius,radius,0);
  37. case ProceduralImageEdge.Bottom:
  38. return new Vector4(0,0,radius,radius);
  39. case ProceduralImageEdge.Left:
  40. return new Vector4(radius,0,0,radius);
  41. default:
  42. return new Vector4(0,0,0,0);
  43. }
  44. }
  45. #endregion
  46. }