PresetSaveWindow.cs 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. using System;
  2. using System.Collections.Generic;
  3. using I2.Loc;
  4. using UnityEngine;
  5. using wf;
  6. namespace SceneEditWindow
  7. {
  8. [AddComponentMenu("SceneEditWindow/PresetSaveWindow")]
  9. public class PresetSaveWindow : BasePhotoWindow
  10. {
  11. public override string windowName
  12. {
  13. get
  14. {
  15. return "PresetSaveIconWindow";
  16. }
  17. }
  18. public override void Awake()
  19. {
  20. base.Awake();
  21. for (int i = 0; i < PresetSaveWindow.termNames.Length; i++)
  22. {
  23. UIWFTabButton uiwftabButton = this.CreateItemObject(this.itemGrit.gameObject, PresetSaveWindow.termNames[i]);
  24. uiwftabButton.name = i.ToString();
  25. EventDelegate.Add(uiwftabButton.onClick, delegate()
  26. {
  27. this.OnClickItem((PresetSaveWindow.SaveType)int.Parse(UIButton.current.name));
  28. });
  29. }
  30. this.UpdateChildren();
  31. }
  32. protected virtual void OnDestroy()
  33. {
  34. foreach (KeyValuePair<string, Texture> keyValuePair in this.texDic)
  35. {
  36. UnityEngine.Object.DestroyImmediate(keyValuePair.Value);
  37. }
  38. this.texDic.Clear();
  39. }
  40. protected void OnClickItem(PresetSaveWindow.SaveType type)
  41. {
  42. if (this.onClickPresetSaveEvent != null)
  43. {
  44. this.onClickPresetSaveEvent(type);
  45. }
  46. }
  47. protected UIWFTabButton CreateItemObject(GameObject parent, string termName)
  48. {
  49. GameObject gameObject = Utility.CreatePrefab(parent, "SceneEdit/WindowParts/PresetSaveItem", true);
  50. gameObject.GetComponentInChildren<Localize>().SetTerm(termName);
  51. return gameObject.GetComponent<UIWFTabButton>();
  52. }
  53. public static readonly string[] termNames = new string[]
  54. {
  55. "SceneEdit/プリセット/スプライト/体と服80",
  56. "SceneEdit/プリセット/スプライト/服80",
  57. "SceneEdit/プリセット/スプライト/体80"
  58. };
  59. [SerializeField]
  60. public SceneEdit sceneEdit;
  61. [SerializeField]
  62. private UIGrid itemGrit;
  63. public Action<PresetSaveWindow.SaveType> onClickPresetSaveEvent;
  64. private Dictionary<string, Texture> texDic = new Dictionary<string, Texture>();
  65. public enum SaveType
  66. {
  67. All,
  68. ClothesOnly,
  69. BodyOnly
  70. }
  71. }
  72. }