-
Notifications
You must be signed in to change notification settings - Fork 797
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #7978 from Unity-Technologies/internal/2022.3/staging
Internal/2022.3/staging
- Loading branch information
Showing
47 changed files
with
734 additions
and
251 deletions.
There are no files selected for viewing
34 changes: 34 additions & 0 deletions
34
Packages/com.unity.render-pipelines.core/Editor/AssetDatabaseHelper.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
using System.Collections.Generic; | ||
using UnityEngine; | ||
|
||
namespace UnityEditor.Rendering | ||
{ | ||
/// <summary> Set of helpers for AssetDatabase operations. </summary> | ||
public static class AssetDatabaseHelper | ||
{ | ||
/// <summary> | ||
/// Finds all assets of type T in the project. | ||
/// </summary> | ||
/// <param name="extension">Asset type extension i.e ".mat" for materials</param> | ||
/// <typeparam name="T">The type of material you are looking for</typeparam> | ||
/// <returns>A IEnumerable object</returns> | ||
public static IEnumerable<T> FindAssets<T>(string extension = null) | ||
{ | ||
string typeName = typeof(T).ToString(); | ||
int i = typeName.LastIndexOf('.'); | ||
if (i != -1) | ||
{ | ||
typeName = typeName.Substring(i+1, typeName.Length - i-1); | ||
} | ||
|
||
string query = !string.IsNullOrEmpty(extension) ? $"t:{typeName} glob:\"**/*{extension}\"" : $"t:{typeName}"; | ||
|
||
foreach (var guid in AssetDatabase.FindAssets(query)) | ||
{ | ||
var asset = AssetDatabase.LoadMainAssetAtPath(AssetDatabase.GUIDToAssetPath(guid)); | ||
if (asset is T castAsset) | ||
yield return castAsset; | ||
} | ||
} | ||
} | ||
} |
3 changes: 3 additions & 0 deletions
3
Packages/com.unity.render-pipelines.core/Editor/AssetDatabaseHelper.cs.meta
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.