Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
2 captures
13 Jun 22 - 14 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
This question was closed Mar 26, 2013 at 08:28 AM by Fattie for the following reason:

click Edit and remove the all caps thanks

avatar image
0
Question by hotozi · Mar 25, 2013 at 05:35 PM · gameobjectarrayinventory

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

Comment
Add comment
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

1 Reply

  • Sort: 
avatar image
1
Best Answer

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();


Comment
Add comment · Show 1 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image hotozi · Mar 27, 2013 at 01:49 AM 0
Share

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

Answers Answers and Comments

11 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

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


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges