您最多选择25个主题
主题必须以中文或者字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符
22 行
898 B
22 行
898 B
using System;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
using Object = UnityEngine.Object;
|
|
|
|
namespace UnityEditor.Perception.Randomization
|
|
{
|
|
static class AssetLoadingUtilities
|
|
{
|
|
public static List<Object> LoadAssetsFromFolder(string folderPath, Type assetType)
|
|
{
|
|
if (!folderPath.StartsWith(Application.dataPath))
|
|
throw new ApplicationException("Selected folder is not an asset folder in this project");
|
|
var assetsPath = "Assets" + folderPath.Remove(0, Application.dataPath.Length);
|
|
var assetIds = AssetDatabase.FindAssets($"t:{assetType.Name}", new[] { assetsPath });
|
|
var assets = new List<Object>();
|
|
foreach (var guid in assetIds)
|
|
assets.Add(AssetDatabase.LoadAssetAtPath(AssetDatabase.GUIDToAssetPath(guid), assetType));
|
|
return assets;
|
|
}
|
|
}
|
|
}
|