UndressWindow.cs 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. using System;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. using wf;
  5. namespace SceneEditWindow
  6. {
  7. [AddComponentMenu("SceneEditWindow/UndressWindow")]
  8. public class UndressWindow : BasePhotoWindow
  9. {
  10. public override string windowName
  11. {
  12. get
  13. {
  14. return "UndressWindow";
  15. }
  16. }
  17. public override void Awake()
  18. {
  19. base.Awake();
  20. bool vba = Product.VBA;
  21. if (vba)
  22. {
  23. this.WindowSize.x = 203f;
  24. base.ResizeWindow();
  25. }
  26. for (int i = 0; i < UndressWindow.IconTexFileNames.Length; i++)
  27. {
  28. UndressWindow.UndressType undressType = (UndressWindow.UndressType)i;
  29. if (undressType != UndressWindow.UndressType.Nude || !vba)
  30. {
  31. UIWFTabButton uiwftabButton = this.CreateItemObject(this.itemGrit.gameObject, UndressWindow.IconTexFileNames[i]);
  32. uiwftabButton.name = i.ToString();
  33. EventDelegate.Add(uiwftabButton.onClick, delegate()
  34. {
  35. this.OnClickItem((UndressWindow.UndressType)int.Parse(UIButton.current.name));
  36. });
  37. }
  38. }
  39. this.UpdateChildren();
  40. }
  41. protected virtual void OnDestroy()
  42. {
  43. foreach (KeyValuePair<string, Texture> keyValuePair in this.texDic)
  44. {
  45. UnityEngine.Object.DestroyImmediate(keyValuePair.Value);
  46. }
  47. this.texDic.Clear();
  48. }
  49. protected void OnClickItem(UndressWindow.UndressType type)
  50. {
  51. if (this.onClickUndressEvent != null)
  52. {
  53. this.onClickUndressEvent(type);
  54. }
  55. }
  56. protected UIWFTabButton CreateItemObject(GameObject parent, string textFileName)
  57. {
  58. GameObject gameObject = Utility.CreatePrefab(parent, "SceneEdit/WindowParts/PoseIconItem", true);
  59. if (!this.texDic.ContainsKey(textFileName))
  60. {
  61. this.texDic.Add(textFileName, ImportCM.CreateTexture(textFileName));
  62. }
  63. UITexture component = gameObject.GetComponent<UITexture>();
  64. component.mainTexture = this.texDic[textFileName];
  65. return gameObject.GetComponent<UIWFTabButton>();
  66. }
  67. public static readonly string[] IconTexFileNames = new string[]
  68. {
  69. "cm3d2_edit_clothesicon_dress.tex",
  70. "cm3d2_edit_clothesicon_lingerie.tex",
  71. "cm3d2_edit_clothesicon_nude.tex"
  72. };
  73. [SerializeField]
  74. public SceneEdit sceneEdit;
  75. [SerializeField]
  76. private UIGrid itemGrit;
  77. public Action<UndressWindow.UndressType> onClickUndressEvent;
  78. private Dictionary<string, Texture> texDic = new Dictionary<string, Texture>();
  79. public enum UndressType
  80. {
  81. Dress,
  82. Lingerie,
  83. Nude
  84. }
  85. }
  86. }