unity resources.loadall
时间: 2024-05-14 16:14:22 浏览: 18
Unity's Resources.LoadAll() method is used to load all assets at a specific path in the project's "Resources" folder. It returns an array of objects, which can be cast to the appropriate type of asset.
For example, if you have a folder called "Materials" in your "Resources" folder, and you want to load all of the materials in that folder, you can use the following code:
```
Material[] materials = Resources.LoadAll<Material>("Materials");
```
This will load all of the materials in the "Materials" folder and store them in the "materials" array.
Note that using Resources.LoadAll() can be inefficient and slow, especially if you have a large number of assets in the folder you are loading from. It is generally recommended to use other methods (such as AssetBundle) for loading assets at runtime, especially for larger projects.
相关推荐
![rar](https://img-home.csdnimg.cn/images/20210720083606.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)