I am working on a inventory system and am having a transform child out of bounds error.
my Hierarchy:
>InventoryCanavas
---->Hotbar
-------->Slot (1)
-------->Slot (2)
---------------->CubeIMG
---------------------->Cube
------- >Slot (3)
-------- >Slot (4)
-------- >Slot (5)
-------- >Slot (6)
-------- >Slot (7)
-------- >Slot (8)
-------- >Slot (9)
-------- >Slot (10)
--END--
so the way it works is index is set by the scroll wheel (I am sure index is correct I have done a lot of testing on it). index then tells this what slot to go to and then takes the child and sends it to my placement script with some data that is found by comparing the child to a list of placeable objects in the game. It the cooses from BLOCK SAW DRILL WELDER. My debug says the error is in the line “placement.objToPlace = hotbar.transform.GetChild(index).GetChild(0).GetChild(0).gameObject;”
the first child of the slot object is to add a graphic to the slot.
the code:
f(hotbar.transform.GetChild(index).transform.childCount == 1)
{
placement.objToPlace = hotbar.transform.GetChild(index).GetChild(0).GetChild(0).gameObject;
for (int i = 0; i < AllObjects.Length; i++)
{
if (hotbar.transform.GetChild(index).GetChild(0).gameObject.name == AllObjects*.name)*
{
Debug.Log("This thing that I am holding has the data: " + AllObjects_DATA*);
placement.type = AllObjects_DATA;
_}
}
}*_