Unity Resources.LoadAsync使用
1、StartCoroutine(函数名)开启一个协程
2、返回值为IEnumerator的函数,函数中有yield return类型返回值,当yield return执行后,才会执行yield return以后的代码块
3、Resources.LoadAsync(资源路径) 异步加载的使用 返回值为ResourceRequest
asset 被加载的资源
isDone 加载是否完成,bool类型
progress 加载的进度
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class test : MonoBehaviour
{
// Start is called before the first frame update
void Start()
{
//开启协程
for(int i =0 ; i<64 ;i++)
{
StartCoroutine(AsyncLoadResources(0,i*28));
}
}
// Update is called once per frame
void Update()
{
}
IEnumerator AsyncLoadResources(int index,int posx)
{
ResourceRequest resourcesRequest = Resources.LoadAsync("CSample" + index, typeof(GameO