Esempio n. 1
0
        public void InitLabelCache(Object[] assets)
        {
            HashSet <Object> newAssetSet = new HashSet <Object>(assets);

            // Init only if new asset
            if (m_CurrentAssetsSet == null || !m_CurrentAssetsSet.SetEquals(newAssetSet))
            {
                List <string> all;
                List <string> partial;
                GetLabelsForAssets(assets, out all, out partial);

                m_AssetLabels = new PopupList.InputData
                {
                    m_CloseOnSelection   = false,
                    m_AllowCustom        = true,
                    m_OnSelectCallback   = AssetLabelListCallback,
                    m_MaxCount           = 15,
                    m_SortAlphabetically = true
                };

                Dictionary <string, float> allLabels = AssetDatabase.GetAllLabels();
                foreach (var pair in allLabels)
                {
                    PopupList.ListElement element = m_AssetLabels.NewOrMatchingElement(pair.Key);
                    if (element.filterScore < pair.Value)
                    {
                        element.filterScore = pair.Value;
                    }
                    element.selected          = all.Any(label => string.Equals(label, pair.Key, StringComparison.OrdinalIgnoreCase));
                    element.partiallySelected = partial.Any(label => string.Equals(label, pair.Key, StringComparison.OrdinalIgnoreCase));
                }
            }

            m_CurrentAssetsSet = newAssetSet;
            m_CurrentChanged   = false;
        }