private int AssetGuidComparer(Asset a, Asset b)
        {
            SourceAsset sourceAssetA = GetSourceAsset(a.Guid);
            SourceAsset sourceAssetB = GetSourceAsset(b.Guid);

            if (sourceAssetA != null && sourceAssetB != null || sourceAssetA == null && sourceAssetB == null)
            {
                return(a.Guid.CompareTo(b.Guid));
            }

            if (sourceAssetA == null)
            {
                return(-1);
            }

            if (sourceAssetB == null)
            {
                return(1);
            }

            return(0);
        }
Exemple #2
0
        private void DrawAssetBundleView()
        {
            m_AssetBundleViewScroll = EditorGUILayout.BeginScrollView(m_AssetBundleViewScroll);
            {
                if (m_SelectedAssetBundle != null)
                {
                    int     index  = 0;
                    Asset[] assets = m_Controller.GetAssets(m_SelectedAssetBundle.Name, m_SelectedAssetBundle.Variant);
                    m_CurrentAssetBundleContentCount = assets.Length;
                    foreach (Asset asset in assets)
                    {
                        SourceAsset sourceAsset = m_Controller.GetSourceAsset(asset.Guid);
                        string      assetName   = sourceAsset != null ? (m_Controller.AssetSorter == AssetSorterType.Path ? sourceAsset.Path : (m_Controller.AssetSorter == AssetSorterType.Name ? sourceAsset.Name : sourceAsset.Guid)) : asset.Guid;
                        EditorGUILayout.BeginHorizontal();
                        {
                            float emptySpace = position.width;
                            bool  select     = IsSelectedAssetInSelectedAssetBundle(asset);
                            if (select != EditorGUILayout.Toggle(select, GUILayout.Width(emptySpace - 12f)))
                            {
                                select = !select;
                                SetSelectedAssetInSelectedAssetBundle(asset, select);
                            }

                            GUILayout.Space(-emptySpace + 24f);
                            GUI.DrawTexture(new Rect(20f, 20f * (index++) + 1f, 16f, 16f), (sourceAsset != null ? sourceAsset.Icon : m_MissingSourceAssetIcon));
                            EditorGUILayout.LabelField(string.Empty, GUILayout.Width(14f), GUILayout.Height(18f));
                            EditorGUILayout.LabelField(assetName);
                        }
                        EditorGUILayout.EndHorizontal();
                    }
                }
                else
                {
                    m_CurrentAssetBundleContentCount = 0;
                }
            }
            EditorGUILayout.EndScrollView();
        }
        public void ScanSourceAssets()
        {
            m_SourceAssets.Clear();
            m_SourceAssetRoot.Clear();

            string[]         sourceAssetSearchPaths = m_SourceAssetSearchPaths.ToArray();
            HashSet <string> tempGuids = new HashSet <string>();

            tempGuids.UnionWith(AssetDatabase.FindAssets(SourceAssetUnionTypeFilter, sourceAssetSearchPaths));
            tempGuids.UnionWith(AssetDatabase.FindAssets(SourceAssetUnionLabelFilter, sourceAssetSearchPaths));
            tempGuids.ExceptWith(AssetDatabase.FindAssets(SourceAssetExceptTypeFilter, sourceAssetSearchPaths));
            tempGuids.ExceptWith(AssetDatabase.FindAssets(SourceAssetExceptLabelFilter, sourceAssetSearchPaths));

            string[] assetGuids = new List <string>(tempGuids).ToArray();
            foreach (string assetGuid in assetGuids)
            {
                string fullPath = AssetDatabase.GUIDToAssetPath(assetGuid);
                if (AssetDatabase.IsValidFolder(fullPath))
                {
                    // Skip folder.
                    continue;
                }

                string       assetPath   = fullPath.Substring(SourceAssetRootPath.Length + 1);
                string[]     splitedPath = assetPath.Split('/');
                SourceFolder folder      = m_SourceAssetRoot;
                for (int i = 0; i < splitedPath.Length - 1; i++)
                {
                    SourceFolder subFolder = folder.GetFolder(splitedPath[i]);
                    folder = subFolder == null?folder.AddFolder(splitedPath[i]) : subFolder;
                }

                SourceAsset asset = folder.AddAsset(assetGuid, fullPath, splitedPath[splitedPath.Length - 1]);
                m_SourceAssets.Add(asset.Guid, asset);
            }
        }
Exemple #4
0
 private bool IsSelectedSourceAsset(SourceAsset sourceAsset)
 {
     return(m_SelectedSourceAssets.Contains(sourceAsset));
 }