Last active
December 13, 2015 21:28
-
-
Save tsubaki/4977341 to your computer and use it in GitHub Desktop.
デリゲートの例
This file contains hidden or 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
delegate void DownloadAction(WWW www); | |
public Texture mainTexture; | |
void Start() | |
{ | |
StartCoroutine(DownloadAndAction(urls[0], SetMainTexture)); | |
} | |
void SetMainTexture(WWW www ) | |
{ | |
mainTexture = www.texture; | |
} | |
IEnumerator DownloadAndAction(string url, DownloadAction act) | |
{ | |
using( WWW www = new WWW(url)) | |
{ | |
while( !www.isDone && string.IsNullOrEmpty(www.error)) { | |
yield return null; | |
} | |
if( act!=null) | |
act(www); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment