How can we load all assets by Type in a folder
Closed this issue · 4 comments
Hi @gmhevinci
I have a folder that has some Scriptable files inside.
How can I use ResourceManager to load all assets by Type inside the folder? (Maybe the same of Unity API: public Object[] LoadAllAssets(Type type);)
I try ResourceManager.Instance.LoadSubAssetsAsync but it not works, maybe it only uses for Sprite and SpriteAtlas
Thank you so much!
There is no concept of "AssetBundle" in the game logic. Depending on the pack rules, the asset object may be pack into any Bundle.
在业务逻辑层并没有“AssetBundle”的概念,因为根据打包规则,资源对象可能被打进任意AB文件里。在业务逻辑层,我们只需要关心资源对象,至于这个资源对象在哪个AB里,我们并不需要知道。
Hi @gmhevinci
Thank you for the detailed explanation, I want to get all the blocks asset in a folder like this code (Just example):
`
IAssetBundle ab = m_Loader.LoadAssetBundle("data/blocks");
yield return ab.AsyncHandler;
AsyncAssets assets = ab.LoadAllAssets();
while (!assets.IsDone)
{
yield return null;
}
Object[] blocks = assets.Assets;
for (int i = 0; i < blocks.Length; i++)
{
Block block = blocks[i] as Block;
m_BlocksMap.Add(block.Type, block);
}
`
How can we get the block array with MotionFramework? Thank you!
I think you need a list of files that be write in Excel or a text config can be generated using a tools.
Look like ConfigManager.cs
public IEnumerator LoadConfigs(List<LoadPair> loadPairs)
{
for(int i=0; i< loadPairs.Count; i++)
{
Type type = loadPairs[i].ClassType;
string location = loadPairs[i].Location;
AssetConfig config = LoadConfig(type, location);
yield return config;
}
}
@gmhevinci Thank you so much! That should be easy to do!