using System; using System.Collections.Generic; using UnityEngine; using wf; namespace SceneEditWindow { [AddComponentMenu("SceneEditWindow/CustomViewWindow")] public class CustomViewWindow : BasePhotoWindow { public List itemList { get; private set; } public override string windowName { get { return "CustomViewWindow"; } } public override void Awake() { base.Awake(); CustomViewItemData.Create(); UIWFTabButton[] componentsInChildren = this.tabPanel.GetComponentsInChildren(); foreach (UIWFTabButton uiwftabButton in componentsInChildren) { EventDelegate.Add(uiwftabButton.onSelect, new EventDelegate.Callback(this.OnClickSelectCategory)); } this.tabPanel.UpdateChildren(); } private void OnDestroy() { foreach (KeyValuePair keyValuePair in this.texDic) { UnityEngine.Object.DestroyImmediate(keyValuePair.Value); } this.texDic.Clear(); } public void Create() { if (this.itemList != null) { return; } this.itemList = new List(); HashSet hashSet = new HashSet(); foreach (SceneEdit.SCategory scategory in this.sceneEdit.CategoryList) { foreach (SceneEdit.SPartsType spartsType in scategory.m_listPartsType) { hashSet.Add(spartsType.m_mpn); foreach (SceneEdit.SMenuItem smenuItem in spartsType.m_listMenu) { hashSet.Add(smenuItem.m_mpn); if (smenuItem.m_eColorSetMPN != MPN.null_mpn) { hashSet.Add(smenuItem.m_eColorSetMPN); } } } } foreach (CustomViewItemData.ItemData itemData in CustomViewItemData.itemList) { if (hashSet.Contains(itemData.mpn) && (!itemData.requestNewFace || PluginData.IsEnabled("GP001") || PluginData.IsEnabled("GP001FB")) && (!itemData.requestFBFace || PluginData.IsEnabled("GP001FB"))) { if (!this.texDic.ContainsKey(itemData.iconTexName)) { this.texDic.Add(itemData.iconTexName, ImportCM.CreateTexture(itemData.iconTexName)); } CustomViewItem componentInChildren = Utility.CreatePrefab(this.pageItemGrits[itemData.page].gameObject, "SceneEdit/WindowParts/CustomItem", true).GetComponentInChildren(); componentInChildren.sceneEdit = this.sceneEdit; componentInChildren.mpn = itemData.mpn; componentInChildren.requestNewFace = itemData.requestNewFace; componentInChildren.requestFBFace = itemData.requestFBFace; componentInChildren.defaultIconTexture = this.texDic[itemData.iconTexName]; componentInChildren.GetComponentInChildren().depth = 15; this.itemList.Add(componentInChildren); } } foreach (UIGrid grid in this.pageItemGrits) { Utility.ResetNGUI(grid); } this.UpdateAllItem(); this.tabPanel.Select(this.tabPanel.GetComponentInChildren()); this.UpdateChildren(); } public bool UpdateAllItem() { bool flag = false; foreach (CustomViewItem customViewItem in this.itemList) { flag |= customViewItem.UpdateIcon(null); } return flag; } private void OnClickSelectCategory() { if (!UIWFSelectButton.selected) { return; } UIWFTabButton[] componentsInChildren = this.tabPanel.GetComponentsInChildren(); for (int i = 0; i < componentsInChildren.Length; i++) { if (componentsInChildren[i] == UIWFSelectButton.current) { for (int j = 0; j < this.pageItemGrits.Length; j++) { this.pageItemGrits[j].transform.localScale = ((j != i) ? Vector3.zero : Vector3.one); } break; } } } [SerializeField] public SceneEdit sceneEdit; [SerializeField] private UIWFTabPanel tabPanel; [SerializeField] private UIGrid[] pageItemGrits; private Dictionary texDic = new Dictionary(); } }