コード例 #1
0
        private void InitAssetSelectionTab()
        {
            UIHelperExtension assetSelectionTabContainer = createNewAsteriskTab(Locale.Get("TLM_CITY_ASSETS_SELECTION"));

            m_defaultAssets = assetSelectionTabContainer.AddTextList(Locale.Get("TLM_DEFAULT_ASSETS"), new Dictionary <string, string>(), delegate(string idx) { }, 340, 250);
            m_prefixAssets  = assetSelectionTabContainer.AddTextList(Locale.Get("TLM_ASSETS_FOR_PREFIX"), new Dictionary <string, string>(), delegate(string idx) { }, 340, 250);
            foreach (Transform t in ((UIPanel)assetSelectionTabContainer.self).transform)
            {
                var panel = t.gameObject.GetComponent <UIPanel>();
                if (panel)
                {
                    panel.width = 340;
                }
            }

            m_prefixAssets.root.backgroundSprite  = "EmptySprite";
            m_prefixAssets.root.color             = Color.white;
            m_prefixAssets.root.width             = 340;
            m_defaultAssets.root.backgroundSprite = "EmptySprite";
            m_defaultAssets.root.width            = 340;
            assetSelectionTabContainer.AddSpace(10);

            m_prefixAssets.EventOnSelect  += M_defaultAssets_eventOnSelect;
            m_defaultAssets.EventOnSelect += M_defaultAssets_eventOnSelect;


            OnButtonClicked reload = delegate
            {
                reloadAssetsList(m_prefixSelection.selectedIndex);
            };

            assetSelectionTabContainer.AddButton(Locale.Get("TLM_ADD"), delegate
            {
                if (m_defaultAssets.unselected)
                {
                    return;
                }
                var selected = m_defaultAssets.selectedItem;
                if (selected == null || selected.Equals(default(string)))
                {
                    return;
                }
                addAssetToPrefixDropDownSelection(m_systemTypeDropDown.selectedIndex, (uint)(m_prefixSelection.selectedIndex - 1), selected);
                reload();
            });
            assetSelectionTabContainer.AddButton(Locale.Get("TLM_REMOVE"), delegate
            {
                if (m_prefixAssets.unselected)
                {
                    return;
                }
                var selected = m_prefixAssets.selectedItem;
                if (selected == null || selected.Equals(default(string)))
                {
                    return;
                }
                removeAssetFromPrefixDropDownSelection(m_systemTypeDropDown.selectedIndex, (uint)(m_prefixSelection.selectedIndex - 1), selected);
                reload();
            });

            assetSelectionTabContainer.AddButton(Locale.Get("TLM_REMOVE_ALL"), delegate
            {
                removeAllAssetsFromPrefixDropDownSelection(m_systemTypeDropDown.selectedIndex, (uint)(m_prefixSelection.selectedIndex - 1));
                reload();
            });
            assetSelectionTabContainer.AddButton(Locale.Get("TLM_RELOAD"), delegate
            {
                reload();
            });
            assetSelectionTabContainer.AddSpace(5);

            setPreviewWindow(assetSelectionTabContainer);
        }