UndressWindow.cs 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  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 isPublic = Product.isPublic;
  21. if (isPublic)
  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 || !isPublic)
  30. {
  31. string textFileName = UndressWindow.IconTexFileNames[i];
  32. if (i == 1 && Product.isPublic)
  33. {
  34. textFileName = "cm3d2_edit_clothesicon_spats.tex";
  35. }
  36. UIWFTabButton uiwftabButton = this.CreateItemObject(this.itemGrit.gameObject, textFileName);
  37. uiwftabButton.name = i.ToString();
  38. EventDelegate.Add(uiwftabButton.onClick, delegate()
  39. {
  40. this.OnClickItem((UndressWindow.UndressType)int.Parse(UIButton.current.name));
  41. });
  42. }
  43. }
  44. this.UpdateChildren();
  45. }
  46. protected virtual void OnDestroy()
  47. {
  48. foreach (KeyValuePair<string, Texture> keyValuePair in this.texDic)
  49. {
  50. UnityEngine.Object.DestroyImmediate(keyValuePair.Value);
  51. }
  52. this.texDic.Clear();
  53. }
  54. protected void OnClickItem(UndressWindow.UndressType type)
  55. {
  56. if (this.onClickUndressEvent != null)
  57. {
  58. this.onClickUndressEvent(type);
  59. }
  60. }
  61. protected UIWFTabButton CreateItemObject(GameObject parent, string textFileName)
  62. {
  63. GameObject gameObject = Utility.CreatePrefab(parent, "SceneEdit/WindowParts/PoseIconItem", true);
  64. if (!this.texDic.ContainsKey(textFileName))
  65. {
  66. this.texDic.Add(textFileName, ImportCM.CreateTexture(textFileName));
  67. }
  68. UITexture component = gameObject.GetComponent<UITexture>();
  69. component.mainTexture = this.texDic[textFileName];
  70. return gameObject.GetComponent<UIWFTabButton>();
  71. }
  72. public static readonly string[] IconTexFileNames = new string[]
  73. {
  74. "cm3d2_edit_clothesicon_dress.tex",
  75. "cm3d2_edit_clothesicon_lingerie.tex",
  76. "cm3d2_edit_clothesicon_nude.tex"
  77. };
  78. [SerializeField]
  79. public SceneEdit sceneEdit;
  80. [SerializeField]
  81. private UIGrid itemGrit;
  82. public Action<UndressWindow.UndressType> onClickUndressEvent;
  83. private Dictionary<string, Texture> texDic = new Dictionary<string, Texture>();
  84. public enum UndressType
  85. {
  86. Dress,
  87. Lingerie,
  88. Nude
  89. }
  90. }
  91. }