Problem with taking a gameobject from gameobject list to inventory.

Hi,
I have a little problem with my C# scripts i wrote inspired by some tutorials i recently read. In my little FPS scene, when player picks up an object of class MasterObject, my inventory class (in AddInventory function) checks if the item of that name is stored in prefabList class arrays. If it is it is returned by script in the ResourceManager to inventory. My problem is whenever I try to pick an object, Unity returns
"NullReferenceException: Object reference not set to an instance of an object
Resources.ResourceManager.GetWeapon (System.String name) (at Assets/Scripts/ResourceManager/ResourceManager.cs:18)
Inventory.AddInventory () (at Assets/Scripts/Inventory/Inventory.cs:64)
Inventory.Update () (at Assets/Scripts/Inventory/Inventory.cs:49)
"
I know my code may be a little bit messy, but I just started my adventure with C#.

Inventory Class

using UnityEngine;
using System.Collections;
using System.Collections.Generic;
using Resources;


public class Inventory : MonoBehaviour {
	
	public FPSController controller;
	//private MasterObject mO;
	public bool isToggled = false;
	
	
	
	public GUISkin inventorySkin, inventoryEquip;
	
	public List<MasterObject> inventory = new List<MasterObject>();
	
	/****************************/
	
	private static int invID = 01;
	private Rect invWindow = new Rect(Screen.width/2,Screen.height/2, 500, 400);
	private int inventoryRows = 7;
	private int inventoryCols = 5;
		
	/****************************/
	
	private int buttonWidth = 40;
	private int buttonHeight = 40;
	
	private int invChangeWidth = 60;
	private int invChangeHeight = 20;
	
	/*****TEMP BUTTONS CONTROL****/
	
	public float buttonHorizontalPos;
	public float buttonVerticalPos;
	
	
	void Start () {
		
		

		controller = GetComponentInChildren<FPSController>();
	}
	
	void Update () {
			
	AddInventory();
	if(Input.GetKeyDown(KeyCode.I)) 
		{
			isToggled = !isToggled;
		}


	}
	
	void AddInventory()
	{
		
		MasterObject toPick = controller.pick;
		if(toPick != null)
		{
			GameObject item = Resources.ResourceManager.GetWeapon(toPick.name);
			//MasterObject itemToPick = item.GetComponentInChildren<MasterObject>();
			//inventory.Add(itemToPick);
				
		}
				
	}
	
	void OnGUI()
	{

		if(isToggled == true)
			{
				drawInventory();
			}

	}
	
	public void drawInventory()
	{
		GUI.skin = inventorySkin;
		invWindow = GUI.Window(invID, invWindow, inventoryWindow, ".inventory()"); 
	}
	
	public void inventoryWindow(int id)
	{
		GUI.BeginGroup(new Rect(invWindow.width/2, 20, 240, 370), "");
		
		GUI.skin = inventoryEquip;
		GUI.Box(new Rect(0, 0, 240, 370), "");
		GUI.Button (new Rect(98.12f, 89.99f, buttonWidth, buttonHeight), "Chest");
		GUI.Button (new Rect(34.4f, 164.7f, buttonWidth, buttonHeight), "LH");
		GUI.Button (new Rect(160.4f, 22.81f, buttonWidth, buttonHeight), "Head");
		GUI.Button (new Rect(160.4f, 227.65f, buttonWidth, buttonHeight), "Leg");
		
		/**EQUIP CYBERWARE BUTTONS**/
		GUI.Button (new Rect(27.43f, 338.73f, invChangeWidth, invChangeHeight), "EQUIP");
		GUI.Button (new Rect(150.87f, 338.73f, invChangeWidth, invChangeHeight), "CYBER");

		GUI.EndGroup();
		GUI.BeginGroup(new Rect(10, 20, 240, 370), "");
		
		GUI.skin = null;
		GUI.Box(new Rect(0,0,240,370), "");
		for(int x = 0; x<inventoryCols; x++)
		{
			for(int y = 0; y < inventoryRows; y++)
			{
				GUI.Button(new Rect(15 + (x * buttonWidth), 15 + (y * buttonHeight), buttonWidth, buttonHeight), "");
			}
		}
		GUI.EndGroup();
		GUI.DragWindow();

	}
			

}

PrefabList class

using UnityEngine;
using System.Collections;
using Resources;

public class PrefabList : MonoBehaviour {
	
	public GameObject[] weapons;
	public GameObject[] consumables;
	public GameObject[] ammo;
	public GameObject[] cyberwares;
	public GameObject[] armor;
	public GameObject[] utility;

	void Start () {
	
	}
	
	void Update () {
	
	}
	
	public GameObject GetWeapon(string name)
	{
		for(int i = 0; i < weapons.Length; i++)
		{
			Weapon weapon = weapons*.GetComponent<Weapon>();*

_ if(weapon && weapon.name == name) return weapons*;_
_
}_
_
return null;_
_
}_
_
}*_

ResourceManager class
using UnityEngine;
using System.Collections;

namespace Resources
{
public class ResourceManager : MonoBehaviour {

* private static PrefabList prefablist;*

* public static void SetPrefabList(PrefabList list)*
* {*
* prefablist = list;*
* }*

* public static GameObject GetWeapon(string name)*
* {*

* return prefablist.GetWeapon(name);*
* }*

}
}

MasterObject class (Weapon is MasterObject’s subclass)
using UnityEngine;
using System.Collections;
public class MasterObject : MonoBehaviour {

* public string objectName;*
* public string objectClass;*
* public Texture2D image;*
* public int objectWeight;*
* public string description;*

* public GameObject go;*
* public GameObject item;*

* public bool isGrab = false;*
* public bool isPick = false;*

* public float acceleration = 0;*

* private Vector3 myPosition;*
* protected virtual void Start () {*

* //go = GetComponent();*

* objectName = this.name;*
* objectClass = GetType().Name;*
* }*

* protected virtual void Update () {*

* }*
}

Hi gongalone,

I might be missing something here, but I can’t see any calls to ResourceManager.SetPrefabList(), so the attempt to call prefablist.GetWeapon(name) in the ResourceManager.GetWeapon(name) method is getting a null reference on prefablist. Do you need to set that up in your MasterObject’s Start() method?