Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 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
2
Question by MSFX · Feb 23, 2011 at 10:12 PM · scene-loadingitweenkeydictionary

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

I have a menu which is a duplicate of my main game scene with a flythrough camera.

I have a main game scene where I have several objects which follow iTweenPaths.

I have a duplicate of this scene, just without the player, with a camera flythrough for the main menu.

When the menu scene loads the game scene I get the following:

ArgumentException: An element with the same key already exists in the dictionary. System.Collections.Generic.Dictionary`2[System.String,iTweenPath].Add (System.String key, .iTweenPath value) iTweenPath.OnEnable () (at Assets/Plugins/iTweenPath.cs:17)

I understand the error, keys are unique and the paths are already added within the menu scene but I don't know how to correct it?

Comment
Add comment
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

5 Replies

· Add your reply
  • Sort: 
avatar image
7

Answer by Mike 3 · Feb 23, 2011 at 11:51 PM

Change blah.Add(key, value) to blah[key] = value;

The former throws an exception when adding a duplicate key, while the latter doesn't.

Comment
Add comment · Show 1 · Share
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 MSFX · Feb 25, 2011 at 10:20 AM 0
Share

managed to work around it thanks :)

avatar image
1

Answer by pixelplacement · Feb 24, 2011 at 02:56 AM

Have you tried the most recent iTweenPath from my blog? If so can you send me a project that I can take a look at?

Comment
Add comment · Show 1 · Share
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 MSFX · Feb 25, 2011 at 10:20 AM 0
Share

will send one later today, thanks bob

avatar image
0

Answer by JasonM · Aug 10, 2011 at 04:49 PM

I added these lines before line 17 and I no longer get that error, Im moving the path nodes around in my script, and the changes were not taking effect when I loaded the scene, then left, and loaded the scene again. The 2 lines below are a quick fix, pixelplacement maybe you want to look into this?

if(paths.ContainsKey(pathName.ToLower())) paths.Clear();

     paths.Add(pathName.ToLower(), this);

Comment
Add comment · Share
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
0

Answer by TheOz · Feb 23, 2012 at 03:51 AM

Mike 3 has it right in general terms above.

The actual change to iTweenPath.cs that I made is:

     void OnEnable(){
     if(!paths.ContainsKey(pathName)){
         //paths.Add(pathName.ToLower(), this);
         paths[pathName.ToLower()] = this; // updated from answers.unity3d.com/questions/49137
     }
 }

As you can see I commented out the original line and added the replacement line: paths[pathName.ToLower()] = this;

This fix works my situation when I was instantiating the same prefab from a spawn point multiple times. Hope this makes it easier for all.

Oz.

Comment
Add comment · Show 2 · Share
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 aljndrrr · Feb 14, 2013 at 11:52 PM 0
Share

great solution!

avatar image whassim · Oct 23, 2014 at 07:47 PM 0
Share

Seems like this issue is still around in iTween. Thank you for a great and easy solution!

avatar image
0

Answer by amaceika · Oct 02, 2012 at 04:28 PM

Oh my god thanks guys so much for the easy fix.... Much appreciated...

Comment
Add comment · Show 2 · Share
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 AlucardJay · Oct 02, 2012 at 04:30 PM 0
Share

Hi There. It's great that you found this information helpful. (but ...)

Please don't post comments as answers. Post comments by clicking the [add new comment] button, a window then open for you to type in. Answer fields are for answers only, as this is a knowledge base.

Happy Coding =]

avatar image amaceika · Oct 02, 2012 at 04:36 PM 0
Share

sorry forgot about the comment button

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

6 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Getting the sum of random values from Dictionary 1 Answer

Default Null Value for Key Not Found in Dictionary? 1 Answer

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

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