123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146 |
- 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<int, Texture> 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<UITexture>();
- component.mainTexture = this.texDic[createItemId];
- this.createItemList.Add(PoseIconData.GetItemData(createItemId));
- return gameObject.GetComponent<UIWFTabButton>();
- }
- protected override List<int> CreateItemIdList()
- {
- List<int> list = new List<int>();
- foreach (PoseIconData.ItemData itemData in PoseIconData.itemList)
- {
- list.Add(itemData.id);
- }
- return list;
- }
- public Action<PoseIconData.ItemData> onSelectPauseEvent;
- private Dictionary<int, Texture> texDic = new Dictionary<int, Texture>();
- private List<PoseIconData.ItemData> createItemList = new List<PoseIconData.ItemData>();
- }
- }
|