using System; using System.Collections.Generic; 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.IconTexFileNames.Length; i++) { UIWFTabButton uiwftabButton = this.CreateItemObject(this.itemGrit.gameObject, PresetSaveWindow.IconTexFileNames[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 textFileName) { GameObject gameObject = Utility.CreatePrefab(parent, "SceneEdit/WindowParts/PoseIconItem", true); if (!this.texDic.ContainsKey(textFileName)) { this.texDic.Add(textFileName, ImportCM.CreateTexture(textFileName)); } UITexture component = gameObject.GetComponent(); component.mainTexture = this.texDic[textFileName]; return gameObject.GetComponent(); } public static readonly string[] IconTexFileNames = new string[] { "cm3d2_edit_priset_buttom_clothes_body.tex", "cm3d2_edit_priset_buttom_clothes.tex", "cm3d2_edit_preset_buttom_body.tex" }; [SerializeField] public SceneEdit sceneEdit; [SerializeField] private UIGrid itemGrit; public Action onClickPresetSaveEvent; private Dictionary texDic = new Dictionary(); public enum SaveType { All, ClothesOnly, BodyOnly } } }