Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 14 Next capture
2021 2022 2023
2 captures
12 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 /
avatar image
0
Question by BrandonKirkley · Jan 31, 2020 at 07:32 PM · exceptionkeydictionarynot found

The Given Key cannot be found in the Dictionary and I have no idea why. Worked perfectly before.

I am getting the error of:

 KeyNotFoundException: The given key was not present in the dictionary.
 System.Collections.Generic.Dictionary`2[TKey,TValue].get_Item (TKey key) (at <437ba245d8404784b9fbab9b439ac908>:0)
 numberlist.Update () (at Assets/Scripts/numberlist.cs:87)
 

I've been looking up information on this error but I don't know how the other questions can apply to my code. The weird thing is, this code was working perfectly and then one day I open up Unity and it's no longer working. I don't think I changed anything.

The code for this is below. I updated Unity recently, maybe there was a change in there? I'm so confused. If anyone can help, thank you so so so so so so so so so much! ^u^

 using System;
 using System.Collections;
 using System.Collections.Generic;
 using UnityEngine;
 using UnityEngine.UI;
 
 public class numberlist : MonoBehaviour
 {
     public static Transform THESEARETHECOORDINATESOFSLOTONE;
     public static Transform THESEARETHECOORDINATESOFSLOTTWO;
     public static Transform THESEARETHECOORDINATESOFSLOTTHREE;
 
     public static float THISISTHELITERALSLOTONE;
     public static float THISISTHELITERALSLOTTWO;
     public static float THISISTHELITERALSLOTTHREE;
 
     public GameObject CanvasObject;
 
 
 
 
 
     //public GameObject Script“Character Saying This” Memory of “ Character Remembering It ” “Clue Info”.
 
     public GameObject ScriptJONASMemoryofTESTPeterSelfish;
     public GameObject ScriptJONASCafeteriaBleach;
     public GameObject ScriptJONASSawAlice;
     public GameObject ScriptJONASArgueSylvia;
     public GameObject ScriptJONASJungSmoke;
 
 
 
 
 
     public static List<float> THISISTHEACTUALLIST = new List<float>() { 0, 0, 0 };
     public static Dictionary<float, GameObject> ObjectsTable = new Dictionary<float, GameObject>();
     
     //TIP : DoNotDestroyOnLoad(Object object) on anything if you wanna save it between scenes.
     void Start()
     {
 
         THESEARETHECOORDINATESOFSLOTONE = movetheui.MovingSlotOneCoordinates;
         THESEARETHECOORDINATESOFSLOTTWO = movetheui.MovingSlotTwoCoordinates;
         THESEARETHECOORDINATESOFSLOTTHREE = movetheui.MovingSlotThreeCoordinates;
 
         CanvasObject = GameObject.Find("Clue Holder");
         DontDestroyOnLoad(CanvasObject);
 
 
 
         //Script“Character Saying This” Memory of “ Character Remembering It ” “Clue Info”. = GameObject.Find(“Character Saying This” Memory of “ Character Remembering It ” “Clue Info”.)
         //Script“Character Saying This” Memory of “ Character Remembering It ” “Clue Info”.SetActive(false);
         ScriptJONASMemoryofTESTPeterSelfish = GameObject.Find("JONAS Memory of TEST Peter Selfish");
         ScriptJONASCafeteriaBleach = GameObject.Find("JONAS Cafeteria Bleach");
         ScriptJONASSawAlice = GameObject.Find("JONAS Alice Saw");
         ScriptJONASArgueSylvia = GameObject.Find("JONAS Sylvia Argue");
         ScriptJONASJungSmoke = GameObject.Find("JONAS Jung Smoke");
 
 
 
         //Object table
 
         //ObjectsTable.Add(Number, Script“Character Saying This” Memory of “ Character Remembering It ” “Clue Info”.);
 
         ObjectsTable.Add(1, ScriptJONASMemoryofTESTPeterSelfish);
         ObjectsTable.Add(2, ScriptJONASCafeteriaBleach);
         ObjectsTable.Add(3, ScriptJONASSawAlice);
         ObjectsTable.Add(4, ScriptJONASArgueSylvia);
         ObjectsTable.Add(5, ScriptJONASJungSmoke);
 
 
 
 
     }
 
     // Update is called once per frame
     void Update()
     {
         THESEARETHECOORDINATESOFSLOTONE = movetheui.MovingSlotOneCoordinates;
         THESEARETHECOORDINATESOFSLOTTWO = movetheui.MovingSlotTwoCoordinates;
         THESEARETHECOORDINATESOFSLOTTHREE = movetheui.MovingSlotThreeCoordinates;
 
         float slot1id = THISISTHEACTUALLIST[0];
         float slot2id = THISISTHEACTUALLIST[1];
         float slot3id = THISISTHEACTUALLIST[2];
 
         ObjectsTable[slot1id].SetActive(true);
         ObjectsTable[slot1id].transform.position = THESEARETHECOORDINATESOFSLOTONE.position;
         ObjectsTable[slot2id].SetActive(true);
         ObjectsTable[slot2id].transform.position = THESEARETHECOORDINATESOFSLOTTWO.position;
         ObjectsTable[slot3id].SetActive(true);
         ObjectsTable[slot3id].transform.position = THESEARETHECOORDINATESOFSLOTTHREE.position;
     }
 }

Comment
Add comment · Show 1
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 sacredgeometry · Jan 31, 2020 at 10:37 PM 0
Share

Firstly, your casing is all over the place. There are language conventions and you should ad hear to them because it means its easier to understand your code because it will look like all other well written code and most importantly the .NET framework.

Right now thats said and done.

What is it that you are trying to do?

0 Replies

· Add your reply
  • Sort: 

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

119 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 avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

[SOLVED] Key Not Found Exception - XCODE 1 Answer

get key of item from dictionary based on value c# 1 Answer

iTween Paths : Element with the same key already exists in the dictionary 5 Answers

KeyNotFoundException: The given key was not present in the dictionary 1 Answer

C# Auto Generated Key with Variable (Hash, Metadata, etc.) 2 Answers


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