Skip to content

Instantly share code, notes, and snippets.

@nick-betawave
Created April 26, 2017 23:19
Show Gist options
  • Save nick-betawave/735e50bf74d8d777ae523297b8193be1 to your computer and use it in GitHub Desktop.
Save nick-betawave/735e50bf74d8d777ae523297b8193be1 to your computer and use it in GitHub Desktop.
Instantiating resources through `Resources.Load` in Unity
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Foo : MonoBehaviour
{
void Start() {
// WORKS
//Instantiate(Resources.Load("BouncyBall", typeof(GameObject)));
// DOESN'T WORK
//Instantiate(Resources.Load("..\\Resources\\BouncyBall", typeof(GameObject)));
// DOESN'T WORK
//Instantiate(Resources.Load("../Resources/BouncyBall", typeof(GameObject)));
// WORKS
//Instantiate(Resources.Load("Test/BouncyBall", typeof(GameObject)));
// WORKS
//Instantiate(Resources.Load("Test/Test2/BouncyBall", typeof(GameObject)));
// WORKS
//Instantiate(Resources.Load("Test\\BouncyBall", typeof(GameObject)));
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment