Created
August 20, 2014 15:41
-
-
Save tsubaki/d312826eb0254910e595 to your computer and use it in GitHub Desktop.
擬似非同期の読込
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 UnityEngine; | |
using System.Collections; | |
public class InstantateAsyncManager : MonoBehaviour { | |
public static InstantateAsyncManager Instance; | |
void Awake () { | |
Instance = this; | |
} | |
public static void InstanceAsync(GameObject[] objects, Transform self) | |
{ | |
Instance.StartCoroutine(Instance.InstanceObjects(objects, self)); | |
} | |
public IEnumerator InstanceObjects(GameObject[] objects, Transform self) | |
{ | |
self.gameObject.SetActive(false); | |
foreach( var obj in objects) | |
{ | |
var item = (GameObject)GameObject.Instantiate(obj); | |
item.transform.parent = self; | |
yield return null; | |
} | |
self.gameObject.SetActive(true); | |
} | |
} |
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 UnityEngine; | |
using System.Collections; | |
using System.Collections.Generic; | |
public class Test : MonoBehaviour | |
{ | |
public GameObject[] objects; | |
void Awake() | |
{ | |
InstantateAsyncManager.InstanceAsync(objects, transform); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Test.csじゃなくてTest.caになってます