- Home /
Question by
Mithrilshadow · Apr 05, 2013 at 06:44 PM ·
resource.load
Can't figure out resource.load
I am trying to learn how to use resource.load. I made a folder called Resources and put a prefab into said folder. Its just a sphere primitive colored red. Its called Red_Ball.
but it won't instantiate.
here is my test code:
using UnityEngine;
using System.Collections;
public class ResourceTest : MonoBehaviour {
GameObject ball ;
// Use this for initialization
void Start () {
ball = Resources.Load("Red_Ball") as GameObject;
GameObject go = Instantiate(ball, Vector3.up, Quaternion.identity) as GameObject;
}
// Update is called once per frame
void Update () {
}
}
Comment
Answer by SrBilyon · Apr 06, 2013 at 10:53 PM
Lets try [Tested]:
using UnityEngine;
using System.Collections;
public class ResourceTest : MonoBehaviour {
// Use this for initialization
void Start () {
GameObject go = Instantiate((GameObject)Resources.Load("Red_Ball"), Vector3.up, Quaternion.identity) as GameObject;
}
// Update is called once per frame
void Update () {
}
}
Your answer
![](https://koobas.hobune.stream/wayback/20220613095750im_/https://answers.unity.com/themes/thub/images/avi.jpg)