1

I use iTween a lot and it was OK for most of the time until yesterday, I am getting and error suddenly:

NullReferenceException: Object reference not set to an instance of an object iTween.RetrieveArgs () (at Assets/Plugins/Pixelplacement/iTween/iTween.cs:6811) iTween.Awake () (at Assets/Plugins/Pixelplacement/iTween/iTween.cs:6559) UnityEngine.Object:Instantiate(Object, Vector3, Quaternion)

Initially every time I start the game I get 320 calls of these errors but later it accumulates to 720 and now 999+. I am not sure why it accumulate even though I start the game from scratch all together. Any suggestion?

UPDATE:

To an extend, I believe it is due to Sourcetree that I use for version control. I believe it somehow mess up the meta file or make unity have some sort of conflict internally while looking at iTween.cs.

sooon
  • 4,718
  • 8
  • 63
  • 116
  • Since there are different possible versions of iTween (with different line numbers), can you post the code where NullReferenceException happens? – Max Yankov May 06 '15 at 08:44
  • I redownload the latest version and still same problem persist, this is line 6811:`id=(string)tweenArguments["id"];` and this is line 6559:`RetrieveArgs();` and my code that affected:`GameObject instance2 = (GameObject)Instantiate(manprefab,new Vector3(j*3f, 50f, 0f), Quaternion.Euler(0, 0, 0));`, which doesn't have anything to do with `iTween`. – sooon May 06 '15 at 08:55
  • Wait, what "my code that affected" means? What exactly is the connection between this error and this line of your code? – Max Yankov May 06 '15 at 08:59
  • There is no connection at all. but when console present the error it give me these 3 lines. that is why i don't understand. – sooon May 06 '15 at 09:14
  • I see. I suspect that the object you're instantiating has an `iTween` component on it, am I correct? Then, of course the instantiation would result in `Awake` call. – Max Yankov May 06 '15 at 09:20

4 Answers4

1

I had the exact same error. I found out that by some bug in iTween it had dynamically added multiple iTween script components to one of my prefabs. As soon as I removed them, my errors disappeared.

I suggest you go through your prefabs

0

The order of script execution in Unity could be the problem. I had this problem days ago and the solution was to go to

Edit->Project Settings->Script Execution Order

then put the script that is been accessed from iTween.cs:6559 to run first. I was getting the same error randomly but they longer appear once I did it. Hopefully that will solve your problem.

Programmer
  • 121,791
  • 22
  • 236
  • 328
  • Can you give more detail example? – sooon May 06 '15 at 03:53
  • The error is coming from iTween.cs. What function/class is been called where this error is coming from. If the error is coming from Assets/Plugins/Pixelplacement/iTween/iTween.cs:6811 ? Open that the iTween code and go to line 6811. Look for a function that is been called from this line. If the fuction is DoSomething.exit(), then you know that the DoSomething is the class name. Go to Edit->Project Settings->Script Execution Order and make DoSomething class to be the first script to in the execution order. Do the same thing to Assets/Plugins/Pixelplacement/iTween/iTween.cs:6559 – Programmer May 06 '15 at 04:00
  • I just tried it and it seems to cost more problem. I believe it has to do with .meta data since it accumulate even I restart `Unity3d`. – sooon May 06 '15 at 04:17
  • I still stand with the script execution idea. You want to post the line of code at (at Assets/Plugins/Pixelplacement/iTween/iTween.cs:6811) and (at Assets/Plugins/Pixelplacement/iTween/iTween.cs:6559)? – Programmer May 06 '15 at 04:21
  • 1
    If your code correctness relies on such external factors as script execution order, it's prone to break in the future again, and debugging would be a pain. I would rather investigate why exactly does script execution order matter here and remove this implicit dependency. – Max Yankov May 06 '15 at 08:43
0

I am not sure whether I had the same reason for the bug but this is how I solved it.

The objects I was running the itween on, were in the scene. When I made sure that the references I was using to invoke new instances were from a prefab and not references to objects in the scene - it worked.

Omey Salvi
  • 23
  • 3
-1

In the Awake function, iTween.Init (every object on the itween is applied), as documented by the PixelPlacement

Rahul Rajput
  • 298
  • 4
  • 11