Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
擬似非同期の読込
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

This comment has been minimized.

Copy link

@Densyakun Densyakun commented Oct 29, 2016

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

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