Skip to content

Instantly share code, notes, and snippets.

@kuanyingchou
Last active January 1, 2016 19:59
Show Gist options
  • Save kuanyingchou/8193828 to your computer and use it in GitHub Desktop.
Save kuanyingchou/8193828 to your computer and use it in GitHub Desktop.
using UnityEngine;
using System.Collections;
public class Main : MonoBehaviour {
private GameObject prefab;
public void Update() {
Debug.Log(Time.frameCount);
if(Time.frameCount == 5) {
Load();
Instantiate();
}
}
private void Load() {
Debug.Log("loading resource");
prefab = (GameObject)Resources.Load("obj", typeof(GameObject));
Debug.Log("done loading resource");
}
private void Instantiate() {
Debug.Log("instantiating prefab");
GameObject obj =
GameObject.Instantiate(
prefab,
Vector3.zero,
Quaternion.identity
) as GameObject;
Debug.Log("done instantiating prefab");
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment