Beispiel #1
0
        private void DrawResourceView()
        {
            m_ResourceViewScroll = EditorGUILayout.BeginScrollView(m_ResourceViewScroll);
            {
                if (m_SelectedResource != null)
                {
                    int     index  = 0;
                    Asset[] assets = m_Controller.GetAssets(m_SelectedResource.Name, m_SelectedResource.Variant);
                    m_CurrentResourceContentCount = 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     = IsSelectedAssetInSelectedResource(asset);
                            if (select != EditorGUILayout.Toggle(select, GUILayout.Width(emptySpace - 12f)))
                            {
                                select = !select;
                                SetSelectedAssetInSelectedResource(asset, select);
                            }

                            GUILayout.Space(-emptySpace + 24f);
#if UNITY_2019_3_OR_NEWER
                            GUI.DrawTexture(new Rect(20f, 20f * index++ + 3f, 16f, 16f), sourceAsset != null ? sourceAsset.Icon : m_MissingSourceAssetIcon);
                            EditorGUILayout.LabelField(string.Empty, GUILayout.Width(16f), GUILayout.Height(18f));
#else
                            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));
#endif
                            EditorGUILayout.LabelField(assetName);
                        }
                        EditorGUILayout.EndHorizontal();
                    }
                }
                else
                {
                    m_CurrentResourceContentCount = 0;
                }
            }
            EditorGUILayout.EndScrollView();
        }
Beispiel #2
0
        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);
        }
Beispiel #3
0
        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[] guids = new List <string>(tempGuids).ToArray();
            foreach (string guid in guids)
            {
                string fullPath = AssetDatabase.GUIDToAssetPath(guid);
                if (AssetDatabase.IsValidFolder(fullPath))
                {
                    // Skip folder.
                    continue;
                }

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

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