using System; using System.Collections.Generic; using UnityEngine; using wf; namespace SceneEditWindow { [AddComponentMenu("SceneEditWindow/UndressWindow")] public class UndressWindow : BasePhotoWindow { public override string windowName { get { return "UndressWindow"; } } public override void Awake() { base.Awake(); for (int i = 0; i < UndressWindow.IconTexFileNames.Length; i++) { UIWFTabButton uiwftabButton = this.CreateItemObject(this.itemGrit.gameObject, UndressWindow.IconTexFileNames[i]); uiwftabButton.name = i.ToString(); EventDelegate.Add(uiwftabButton.onClick, delegate() { this.OnClickItem((UndressWindow.UndressType)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(UndressWindow.UndressType type) { if (this.onClickUndressEvent != null) { this.onClickUndressEvent(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_clothesicon_dress.tex", "cm3d2_edit_clothesicon_lingerie.tex", "cm3d2_edit_clothesicon_nude.tex" }; [SerializeField] public SceneEdit sceneEdit; [SerializeField] private UIGrid itemGrit; public Action onClickUndressEvent; private Dictionary texDic = new Dictionary(); public enum UndressType { Dress, Lingerie, Nude } } }