Exemple #1
0
        internal static IEnumerable <TextAsset> GetAssets(this SourceBase source, AssetDeclarationAttributeBase attribute)
        {
            if (attribute.GetDeclarationType() == DeclarationType.Single ||
                attribute.GetIsSingleFile())
            {
                if (!source.IsSingle)
                {
                    yield break;
                }

                var singleSource = source as SingleSource;
                if (singleSource == null)
                {
                    yield break;
                }

                var asset = singleSource.GetAsset(attribute.Group);
                if (asset != null)
                {
                    yield return(asset);
                }
            }
            else
            {
                var singleSource = source as SingleSource;
                if (singleSource != null)
                {
                    var asset = singleSource.GetAsset(attribute.Group);
                    if (asset != null)
                    {
                        yield return(asset);
                    }
                }
                else
                {
                    var folderPath = GetAssetPathFolder(source.GetAssetPath());
                    var assetPaths = AssetDatabase.FindAssets($"t:{nameof(TextAsset)}", new[] { folderPath })
                                     .Select(AssetDatabase.GUIDToAssetPath)
                                     .Where(IsSupportedTextAssetPath)
                                     .ToArray();

                    var multiSource = source as FolderSource;
                    if (multiSource == null)
                    {
                        yield break;
                    }

                    foreach (var assetPath in assetPaths)
                    {
                        if (multiSource.IsRecursive ||
                            GetAssetPathFolder(assetPath) == folderPath)
                        {
                            yield return(AssetDatabase.LoadAssetAtPath <TextAsset>(assetPath));
                        }
                    }
                }
            }
        }
Exemple #2
0
 public override string ToString()
 {
     return($"{Attribute.Group}({Attribute.GetDeclarationType()}<{RootType.Name}>)");
 }
Exemple #3
0
 public override string ToString()
 {
     return($"{RootType} {Attribute.GetDeclarationType()}");
 }