Skip to content

Instantly share code, notes, and snippets.

@tsubaki
Created August 20, 2014 15:41
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tsubaki/d312826eb0254910e595 to your computer and use it in GitHub Desktop.
Save tsubaki/d312826eb0254910e595 to your computer and use it in GitHub Desktop.
擬似非同期の読込
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);
}
}
using UnityEngine;
using System.Collections;
using System.Collections.Generic;
public class Test : MonoBehaviour
{
public GameObject[] objects;
void Awake()
{
InstantateAsyncManager.InstanceAsync(objects, transform);
}
}
@Densyakun
Copy link

Test.csじゃなくてTest.caになってます

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment