SubSlotEditItem.cs 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. using System;
  2. using UnityEngine;
  3. public class SubSlotEditItem : MonoBehaviour
  4. {
  5. public bool frameVisible
  6. {
  7. get
  8. {
  9. return this.frameObject.activeSelf;
  10. }
  11. set
  12. {
  13. this.frameObject.SetActive(value);
  14. }
  15. }
  16. public SceneEdit.SMenuItem menuItem { get; private set; }
  17. public Maid maid
  18. {
  19. get
  20. {
  21. return (!(this.sceneEdit != null)) ? null : this.sceneEdit.maid;
  22. }
  23. }
  24. private void Awake()
  25. {
  26. this.button = base.GetComponentInChildren<UIButton>(true);
  27. EventDelegate.Add(this.button.onClick, new EventDelegate.Callback(this.OnClickEvent));
  28. this.frameObject = UTY.GetChildObject(base.gameObject, "Frame", false);
  29. this.frameVisible = false;
  30. }
  31. public bool SetItem(string menuFileName)
  32. {
  33. if (this.maid.GetSubProp(this.targetMpn, this.sloatNo) != null)
  34. {
  35. return false;
  36. }
  37. this.maid.SetSubProp(this.targetMpn, this.sloatNo, menuFileName, 0);
  38. return true;
  39. }
  40. public bool SetItem(SceneEdit.SMenuItem menu)
  41. {
  42. return this.SetItem(menu.m_strMenuFileName);
  43. }
  44. public bool UpdateSloatInformation()
  45. {
  46. NDebug.Assert(this.targetMpn != MPN.null_mpn, "MPNの設定がnullです");
  47. SubProp subProp = this.sceneEdit.maid.GetSubProp(this.targetMpn, this.sloatNo);
  48. if (subProp == null || !this.sceneEdit.m_menuRidDic.ContainsKey(subProp.nFileNameRID))
  49. {
  50. MaidProp prop = this.sceneEdit.maid.GetProp(this.targetMpn);
  51. if (prop != null && this.sceneEdit.m_menuRidDic.ContainsKey(prop.nFileNameRID))
  52. {
  53. this.menuItem = this.sceneEdit.m_menuRidDic[prop.nFileNameRID];
  54. if (this.menuItem.m_texIconRef != null)
  55. {
  56. this.button.normalSprite2D = Sprite.Create(this.menuItem.m_texIconRef, new Rect(0f, 0f, (float)this.menuItem.m_texIconRef.width, (float)this.menuItem.m_texIconRef.height), Vector2.zero);
  57. }
  58. }
  59. this.menuItem = null;
  60. this.button.isEnabled = false;
  61. return false;
  62. }
  63. this.menuItem = this.sceneEdit.m_menuRidDic[subProp.nFileNameRID];
  64. if (this.menuItem.m_texIconRef != null)
  65. {
  66. this.button.normalSprite2D = Sprite.Create(this.menuItem.m_texIconRef, new Rect(0f, 0f, (float)this.menuItem.m_texIconRef.width, (float)this.menuItem.m_texIconRef.height), Vector2.zero);
  67. }
  68. this.button.isEnabled = true;
  69. return true;
  70. }
  71. private void OnClickEvent()
  72. {
  73. if (this.onClickEvent != null)
  74. {
  75. this.onClickEvent(this);
  76. }
  77. }
  78. public SceneEdit sceneEdit;
  79. public MPN targetMpn;
  80. public int sloatNo;
  81. public Action<SubSlotEditItem> onClickEvent;
  82. private UIButton button;
  83. private GameObject frameObject;
  84. }