using System; using System.Collections.Generic; using UnityEngine; using wf; namespace SceneEditWindow { [AddComponentMenu("SceneEditWindow/PauseIconWindow")] public class PoseIconWindow : BaseIconWindow { public int selectedIconId { get; private set; } public override string windowName { get { return "PauseIconWindow"; } } public override void Awake() { PoseIconData.Create(); base.Awake(); } protected virtual void OnDestroy() { foreach (KeyValuePair keyValuePair in this.texDic) { UnityEngine.Object.DestroyImmediate(keyValuePair.Value); } this.texDic.Clear(); } public void Exec(int poseId) { if (!this.tabButtonDic.ContainsKey(poseId)) { Debug.LogError("ポーズ番号[" + poseId.ToString() + "]のポーズが見つかりませんでした"); return; } this.tabPanel.Select(this.tabButtonDic[poseId]); } public void NextPose() { if (this.createItemList.Count <= 1 || this.selectedIconId < 0) { return; } int num = int.MinValue; for (int i = 0; i < this.createItemList.Count; i++) { if (this.createItemList[i].id == this.selectedIconId) { num = this.createItemList[0].id; if (i + 1 < this.createItemList.Count) { num = this.createItemList[i + 1].id; } break; } } if (num != -2147483648) { this.Exec(num); } } public void PrevPose() { if (this.createItemList.Count <= 1 || this.selectedIconId < 0) { return; } int num = int.MinValue; for (int i = 0; i < this.createItemList.Count; i++) { if (this.createItemList[i].id == this.selectedIconId) { num = this.createItemList[this.createItemList.Count - 1].id; if (0 <= i - 1) { num = this.createItemList[i - 1].id; } break; } } if (num != -2147483648) { this.Exec(num); } } public void ReleaseSelect() { UIWFTabButton selectButtonObject = this.tabPanel.GetSelectButtonObject(); if (selectButtonObject != null) { selectButtonObject.SetSelect(false); this.tabPanel.ResetSelect(); } } protected override void OnSelectItem(int selectItemId) { PoseIconData.ItemData itemData = PoseIconData.GetItemData(selectItemId); this.selectedIconId = itemData.id; if (this.onSelectPauseEvent != null) { this.onSelectPauseEvent(itemData); } } protected override UIWFTabButton CreateItemObject(GameObject parent, int createItemId) { GameObject gameObject = Utility.CreatePrefab(parent, "SceneEdit/WindowParts/PoseIconItem", true); if (!this.texDic.ContainsKey(createItemId)) { PoseIconData.ItemData itemData = PoseIconData.GetItemData(createItemId); this.texDic.Add(createItemId, ImportCM.CreateTexture(itemData.fileSystem, itemData.iconTexName)); } UITexture component = gameObject.GetComponent(); component.mainTexture = this.texDic[createItemId]; this.createItemList.Add(PoseIconData.GetItemData(createItemId)); return gameObject.GetComponent(); } protected override List CreateItemIdList() { List list = new List(); foreach (PoseIconData.ItemData itemData in PoseIconData.itemList) { list.Add(itemData.id); } return list; } public Action onSelectPauseEvent; private Dictionary texDic = new Dictionary(); private List createItemList = new List(); } }