ResourceRequest 资源请求

从资源包异步加载请求。

变量说明
asset正被加载的资源对象。(只读)
  1. using UnityEngine;
  2. using System.Collections;
  3. public class ExampleClass : MonoBehaviour {
  4. void Start() {
  5. StartCoroutine(LoadTexture());
  6. }
  7. IEnumerator LoadTexture() {
  8. GameObject go = GameObject.CreatePrimitive(PrimitiveType.Cube);
  9. ResourceRequest request = Resources.LoadAsync<Texture2D>("glass");
  10. yield return request;
  11. go.renderer.material.mainTexture = request.asset;
  12. }
  13. }

?