how to get dictionary values in unity code example
Example 1: unity dictionary
private Dictionary<float, GameObject> test = new Dictionary<float, GameObject>();
private void addToDictionary()
{
test.Add(10, transform.gameObject);
}
private void printFromDictionary()
{
test.TryGetValue(10, out GameObject result);
print(result);
}
private void deleteFromDictionary()
{
test.Remove(10);
}
Example 2: unity dictionary get value
if (!haveMisionsAsigned && gameRecord.searchedArea == null)
{
for (int i = 0; i < areaArray.Length; i++)
{
if (gameRecord.availableAreas[areaArray[i]])
{
gameRecord.misionsAsigned.Add(misionController.AssignMision("Busqueda", areaArray[i]), areaArray[i].localizations[Random.Range(0,areaArray[i].localizations.Length)].transform);
}
}
}
else if (!haveMisionsAsigned && gameRecord.searchedArea != null)
{
for (int i = 0; i < 3; i++)
{
gameRecord.misionsAsigned.Add(misionController.AssignMision(misionTypeArray[Random.Range(0, misionTypeArray.Length)], gameRecord.searchedArea), gameRecord.searchedArea.localizations[Random.Range(0,gameRecord.searchedArea.localizations.Length)].transform);
}
}
if (!gameRecord.estaEnMarxaUnaMisio)
{
}