MaidAppealComment.cs 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. using System;
  2. using UnityEngine;
  3. namespace Kasizuki
  4. {
  5. public class MaidAppealComment : MonoBehaviour
  6. {
  7. public Action onClickRight { get; set; }
  8. public Action onClickLeft { get; set; }
  9. private void Awake()
  10. {
  11. if (this.m_ButtonRight != null)
  12. {
  13. EventDelegate.Add(this.m_ButtonRight.onClick, delegate
  14. {
  15. if (this.onClickRight != null)
  16. {
  17. this.onClickRight();
  18. }
  19. });
  20. }
  21. if (this.m_ButtonLeft != null)
  22. {
  23. EventDelegate.Add(this.m_ButtonLeft.onClick, delegate
  24. {
  25. if (this.onClickLeft != null)
  26. {
  27. this.onClickLeft();
  28. }
  29. });
  30. }
  31. }
  32. private void OnDestroy()
  33. {
  34. this.DestroyImage();
  35. }
  36. public void DestroyImage()
  37. {
  38. if (this.m_ImageAppealComment != null && this.m_ImageAppealComment.sprite2D != null)
  39. {
  40. if (this.m_ImageAppealComment.sprite2D.texture != null)
  41. {
  42. UnityEngine.Object.DestroyImmediate(this.m_ImageAppealComment.sprite2D.texture, true);
  43. }
  44. this.m_ImageAppealComment.sprite2D = null;
  45. }
  46. }
  47. public void ChangeImage(Texture2D texture)
  48. {
  49. this.DestroyImage();
  50. if (texture == null)
  51. {
  52. return;
  53. }
  54. Sprite sprite = Sprite.Create(texture, new Rect(0f, 0f, (float)texture.width, (float)texture.height), default(Vector2));
  55. sprite.name = "Image _" + texture.name;
  56. this.m_ImageAppealComment.sprite2D = sprite;
  57. }
  58. public void SetEnableEditing(bool isEnable)
  59. {
  60. if (this.m_ButtonRight != null)
  61. {
  62. this.m_ButtonRight.gameObject.SetActive(isEnable);
  63. }
  64. if (this.m_ButtonLeft != null)
  65. {
  66. this.m_ButtonLeft.gameObject.SetActive(isEnable);
  67. }
  68. }
  69. [SerializeField]
  70. private UI2DSprite m_ImageAppealComment;
  71. [SerializeField]
  72. private UIButton m_ButtonRight;
  73. [SerializeField]
  74. private UIButton m_ButtonLeft;
  75. }
  76. }