Dynamically adding a Prefab to the scene

Hi, I’m new to Unity. All I want to do is write a script that takes a Prefab from the Resources folder, and puts it in the scene (as opposed to me dragging and dropping it). My prefab (called “Dummy”) is in a folder called “Resources” within Assets, and I’m trying to load it into a GameObject called guy. However, with my code, I always end up with a null GameObject. What have I done wrong?

using UnityEngine;
using System.Collections;

public class Test : MonoBehaviour {

	public GameObject guy = Resources.Load("Dummy") as GameObject;

	void Start () {
		if (guy == null) {
			Debug.Log ("IT'S NULL!!!");
		}
		Instantiate (guy, new Vector3(400, -2, 115), Quaternion.identity);
	}

	void Update () {
	
	}
}
  1. Don’t call Resources.Load outside methods.

  2. Dummy should be in a Resources folder.

    public class Test : MonoBehaviour {
      public GameObject guy;
         
      void Start () {
        guy = Resources.Load("Dummy") as GameObject;
        if (guy == null) {
          Debug.Log ("IT'S NULL!!!");
        }
        Instantiate (guy, new Vector3(400, -2, 115), Quaternion.identity);
    }
         
      void Update () {
             
      }
    }
    

Oh thanks. However, in the meantime, I have already solved my problem. It was a specific configuration of layers in the scene management