Hello Everyone,
What I am trying to do is simple.
I have a character running around that has the ability to pickup objects.
Upon picking up an object, I want one my blank inventory slots to then have an image of an object.
So far it seems I have the syntax correct:
```csharp
**//declaration of public variables, that I drag and drop from project window:
public Image Slot1; //the first slot in my inventory panel
public Sprite gun; //the image i will use to represent the object I picked up in my inventory**
```
csharp** **Slot1.sprite = gun;** **
Implementing the line above works fine in the Start() function, but anytime I try to Implement this line anywhere else, It does not work. I am getting the error: “Object reference not set to an instance of an object”, whenever I try to implement this line anywhere other than the Start() function.
To summarize, upon picking up an object, I want to change my inventory to have an image of that object in slot 1 of my inventory. This only works when doing this within the Start() function. Like so: (This works only with the Start() function)
How would I go about implementing this outside of the Start() function?
Thanks in advance for any help.
