Last active
November 4, 2016 02:28
-
-
Save enue/5247663c4c91d2fb2019faf512546ef1 to your computer and use it in GitHub Desktop.
【Unity】ResourceLoader
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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