using System; using System.Collections.Generic; using I2.Loc; using UnityEngine; using wf; namespace SceneEditWindow { [AddComponentMenu("SceneEditWindow/PresetSaveWindow")] public class PresetSaveWindow : BasePhotoWindow { public override string windowName { get { return "PresetSaveIconWindow"; } } public override void Awake() { base.Awake(); for (int i = 0; i < PresetSaveWindow.termNames.Length; i++) { UIWFTabButton uiwftabButton = this.CreateItemObject(this.itemGrit.gameObject, PresetSaveWindow.termNames[i]); uiwftabButton.name = i.ToString(); EventDelegate.Add(uiwftabButton.onClick, delegate() { this.OnClickItem((PresetSaveWindow.SaveType)int.Parse(UIButton.current.name)); }); } this.UpdateChildren(); } protected virtual void OnDestroy() { foreach (KeyValuePair keyValuePair in this.texDic) { UnityEngine.Object.DestroyImmediate(keyValuePair.Value); } this.texDic.Clear(); } protected void OnClickItem(PresetSaveWindow.SaveType type) { if (this.onClickPresetSaveEvent != null) { this.onClickPresetSaveEvent(type); } } protected UIWFTabButton CreateItemObject(GameObject parent, string termName) { GameObject gameObject = Utility.CreatePrefab(parent, "SceneEdit/WindowParts/PresetSaveItem", true); gameObject.GetComponentInChildren().SetTerm(termName); return gameObject.GetComponent(); } public static readonly string[] termNames = new string[] { "SceneEdit/プリセット/スプライト/体と服80", "SceneEdit/プリセット/スプライト/服80", "SceneEdit/プリセット/スプライト/体80" }; [SerializeField] public SceneEdit sceneEdit; [SerializeField] private UIGrid itemGrit; public Action onClickPresetSaveEvent; private Dictionary texDic = new Dictionary(); public enum SaveType { All, ClothesOnly, BodyOnly } } }