I’m simply trying to access an array of 2D textures and print “hi” if nothing is in the array slot.
In one script I have:
function Update(){
for(i = 0; i < 49; i++){
if(GetComponent(HUDAndInventory).inventoryTextures *== null){*
-
print("hi");* -
}* - }*
}
In the script “HUDAndInventory” there is a total of 50 textures in the “inventoryTextures” array. I just want to iterate through each texture slot and print “hi” if nothing is assigned to it. I get the error: NullReferenceException: Object reference not set to an instance of an object. Now I understand that this error means I’m trying to reference something that isn’t their, but every thing im referencing and accessing is their. So why do I get this error and how can I fix it?
Thanks!