123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687 |
- 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<string, Texture> 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<UITexture>();
- component.mainTexture = this.texDic[textFileName];
- return gameObject.GetComponent<UIWFTabButton>();
- }
- 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<PresetSaveWindow.SaveType> onClickPresetSaveEvent;
- private Dictionary<string, Texture> texDic = new Dictionary<string, Texture>();
- public enum SaveType
- {
- All,
- ClothesOnly,
- BodyOnly
- }
- }
- }
|