I am working on a menu, using unity's ui. I have an empty scene, with a Canvas, a Panel and an image (square box). There use to be a lot more but this is all I need to get the error.
Attached to the canvas I have the following script attached:
using UnityEngine;
using UnityEngine.UI;
public class CharacterInventory : MonoBehaviour {
public Image Socket0;
void Awake ()
{
Socket0.sprite = Resources.Load("Sprites/spr-Shield-red");
}
}
The "box" is attached to the script in socket0. The "Red Shield" appears in the box as it should however I am getting :> NullReferenceException: Object> reference not set to an instance of an> object CharacterInventory.Start () (at> Assets/Scripts/CharacterInventory.cs:9)
Anyone have any ideas as to why? Over 800 lines of code boils down to 1 line. I have tried a bunch of things but I keep getting the error and I have no idea why!!
Can anyone tell me what is causing this error, and how to fix it.
Thanks in advance
Richard M.
↧