Skip to content

Instantly share code, notes, and snippets.

@GT3000
Created November 18, 2021 21:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save GT3000/2249ade764e28fbaddf11009350f6fce to your computer and use it in GitHub Desktop.
Save GT3000/2249ade764e28fbaddf11009350f6fce to your computer and use it in GitHub Desktop.
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Dictionary : MonoBehaviour
{
public Dictionary<int, Item> itemDictionary = new Dictionary<int, Item>();
void Start()
{
//Make a new item
Weapon sword = new Weapon();
sword.name = "Big Sword";
sword.itemID = 0;
//add the item to the dictionary and set a key of 0
itemDictionary.Add(0, sword);
//prints the item's name in the dictionary using the key
print(itemDictionary[0].name);
}
void Update()
{
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment