Created
November 18, 2021 21:38
-
-
Save GT3000/2249ade764e28fbaddf11009350f6fce to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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