Quantcast
Channel: Latest Questions on Unity Answers
Viewing all articles
Browse latest Browse all 171066

Search for Item in Inventory (Generic List) (Javascript)

$
0
0
Hello! I am relatively new to scripting so please forgive me if my question is astupid :) I want to search for a specific Item in my Intentory. My inventory Code looks like this:+ # Inventory.js static var inventory: List. = new List. (); My items look like this: #Itemclass.js public class ItemClass { var name : String; var icon : Texture2D; var description: String; var ID: int; } Now, if I add some Items to my Inventory, how can i remove specific ones? I thought of finding the Index and then using RemoveAt, however I cannot find a way to find out the Indexnumber. I used IndexOf: var MoneyIndex: int = Inventory.inventory.IndexOf ("Money"); However, that gives me an Error. It also makes sense since only the name variable in the Itemclass is called Money and not the Itemclass itself. Any Ideas anyone?

Viewing all articles
Browse latest Browse all 171066

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>