- Home /
click Edit and remove the all caps thanks
Array Help GameObject Length Inventory
in my inventory script i have this...
var InBag:GameObject[];
var TargetObject:Transform; and this
function Ad(){InBag+=[TargetObject.gameObject];}
Well i already made a script to add object into it...and its all good...i also made a GUI function in an other script to show my items and how many i have...but the things is that i cant assign icon or name or even delete the object from my inventory because once i add it...i cant regain acces to it....CAn somme one help...me just by showing me how i can acces one of the items inside of it....by index....even get acces to the script of one of the game object that is inside....i dont show my other script because it too long and not necessary...SO HELP PLZ !!!! its 2 month i try to get a inventory like this and now im on a good way...!!other videos of inventory doesnt do what i can do....so..!!
so what i need:
showing me how i can acces one of the items inside of it....by index....even get acces to the script of one of the game object that is inside
Answer by Bluestrike · Mar 26, 2013 at 07:54 AM
Here is a load of information using all the different arrays/lists: http://wiki.unity3d.com/index.php?title=Which_Kind_Of_Array_Or_Collection_Should_I_Use%3F
An array has its own functions to add stuff to is as you can see in the link. So if you have an array of gameobjects and want to acces a script on the GO it would look like this:
// Accesing the script on 6th object on the array (0 = item 1)
InBag[5].GetComponent(scriptname).scriptFunctionName();
ya right thx u....but...how do we remove one of the item...i tried RemoveAt....but it says that it not part of gameobject...is there a simple way to just remove the object if we have the object index? or i dobt know...
Follow this Question
Related Questions
Multiple Cars not working 1 Answer
HELP How to remove gameobject from Built-in Arrays 2 Answers
Cant change GO material with multipli material 1 Answer
Inventory Item preview 1 Answer
Array problem? help please! 1 Answer