Skip to content

Instantly share code, notes, and snippets.

@tm8r
Created April 12, 2016 11:20
Show Gist options
  • Save tm8r/8d811f3c1f8e63ea8f4f267a9dc01459 to your computer and use it in GitHub Desktop.
Save tm8r/8d811f3c1f8e63ea8f4f267a9dc01459 to your computer and use it in GitHub Desktop.
instantiate uGUI prefab
using UnityEngine;
public class CanvasManager : MonoBehaviour
{
GameObject buttonPrefab;
void Awake ()
{
buttonPrefab = Resources.Load<GameObject> ("ugui/Button");
}
void Start ()
{
var instance = Instantiate (buttonPrefab);
instance.transform.SetParent (gameObject.transform, false);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment