Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
【Unity】ResourceLoader
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
// Unity5.5.0b10
namespace TSKT
{
public class ResourceLoader<T> : CustomYieldInstruction
where T : UnityEngine.Object
{
ResourceRequest request;
public T Asset { get; private set; }
public override bool keepWaiting
{
get
{
if (request != null && request.isDone)
{
Asset = request.asset as T;
request = null;
}
return request != null;
}
}
public ResourceLoader(string path)
{
request = Resources.LoadAsync<T>(path);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment