Skip to content

Instantly share code, notes, and snippets.

@enue
Last active November 4, 2016 02:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save enue/5247663c4c91d2fb2019faf512546ef1 to your computer and use it in GitHub Desktop.
Save enue/5247663c4c91d2fb2019faf512546ef1 to your computer and use it in GitHub Desktop.
【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