UndressWindow.cs 2.1 KB

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