Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NullReferenceException in v0.9.42 w/ unity2017.2.0f3 #2029

Open
GieziJo opened this issue Nov 15, 2017 · 17 comments

Comments

@GieziJo
Copy link

commented Nov 15, 2017

First: tx for the great work.

There seems to be a NullReferenceException when the plugin tries to call GPGSUpgrader.cs at line 114.
Not sure what the cause is, so I just past the error here:
NullReferenceException: Object reference not set to an instance of an object UnityEditor.InspectorWindow.OnSelectionChange () (at C:/buildslave/unity/build/Editor/Mono/Inspector/InspectorWindow.cs:148) System.Reflection.MonoMethod.Invoke (System.Object obj, BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) (at /Users/builduser/buildslave/mono/build/mcs/class/corlib/System.Reflection/MonoMethod.cs:222) Rethrow as TargetInvocationException: Exception has been thrown by the target of an invocation. System.Reflection.MonoMethod.Invoke (System.Object obj, BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) (at /Users/builduser/buildslave/mono/build/mcs/class/corlib/System.Reflection/MonoMethod.cs:232) System.Reflection.MethodBase.Invoke (System.Object obj, System.Object[] parameters) (at /Users/builduser/buildslave/mono/build/mcs/class/corlib/System.Reflection/MethodBase.cs:115) UnityEditor.HostView.Invoke (System.String methodName, System.Object obj) (at C:/buildslave/unity/build/Editor/Mono/HostView.cs:285) UnityEditor.HostView.Invoke (System.String methodName) (at C:/buildslave/unity/build/Editor/Mono/HostView.cs:278) UnityEditor.HostView.OnSelectionChange () (at C:/buildslave/unity/build/Editor/Mono/HostView.cs:167) UnityEditor.AssetDatabase:Refresh() GooglePlayGames.Editor.GPGSUpgrader:.cctor() (at Assets/GooglePlayGames/Editor/GPGSUpgrader.cs:114) UnityEditor.EditorAssemblies:ProcessInitializeOnLoadAttributes()

Line 114 of GPGSUpgrader.cs is:
AssetDatabase.Refresh();
There might be a problem of communication between unity and the plugin?

Issue #1433 seems related but is not exactly the same.

@adecker-maxgaming

This comment has been minimized.

Copy link

commented Nov 16, 2017

For the sake of similar topics. I also received this null reference error in the same version of unity and the plugin
NullReferenceException: Object reference not set to an instance of an object
GooglePlayServices.AndroidSdkManager+c__AnonStoreyA.<>m__C (GooglePlayServices.AndroidSdkPackageCollection packages)
GooglePlayServices.SdkManager+c__AnonStorey9.<>m__B (GooglePlayServices.Result result)
GooglePlayServices.SdkManagerUtil+c__AnonStorey4.<>m__4 (GooglePlayServices.Result result)
GooglePlayServices.CommandLineDialog+ProgressReporter.Update (GooglePlayServices.CommandLineDialog window)
GooglePlayServices.CommandLineDialog.Update ()
System.Reflection.MonoMethod.Invoke (System.Object obj, BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) (at /Users/builduser/buildslave/mono/build/mcs/class/corlib/System.Reflection/MonoMethod.cs:222)
Rethrow as TargetInvocationException: Exception has been thrown by the target of an invocation.
System.Reflection.MonoMethod.Invoke (System.Object obj, BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) (at /Users/builduser/buildslave/mono/build/mcs/class/corlib/System.Reflection/MonoMethod.cs:232)
System.Reflection.MethodBase.Invoke (System.Object obj, System.Object[] parameters) (at /Users/builduser/buildslave/mono/build/mcs/class/corlib/System.Reflection/MethodBase.cs:115)
UnityEditor.HostView.Invoke (System.String methodName, System.Object obj) (at C:/buildslave/unity/build/Editor/Mono/HostView.cs:285)
UnityEditor.HostView.Invoke (System.String methodName) (at C:/buildslave/unity/build/Editor/Mono/HostView.cs:278)
UnityEditor.HostView.SendUpdate () (at C:/buildslave/unity/build/Editor/Mono/HostView.cs:354)
UnityEditor.EditorApplication.Internal_CallUpdateFunctions () (at C:/buildslave/unity/build/Editor/Mono/EditorApplication.cs:127)

@vladimir-v

This comment has been minimized.

Copy link

commented Nov 21, 2017

Same issue here

@PathToLife

This comment has been minimized.

Copy link

commented Nov 25, 2017

Been there for at least 6 months in one of our projects...
Would love to hear ideas about what's causing this.
It's kinda embarrassing being asked about it then and again... Perhaps I should do a clean plugin install on our app. 👍

I'm guessing the newer versions of GooglePlayGames installs incorrectly if an older version of the plugin existed, most likely unity's fault

Reproducible on unity 5.6.3p1 and 2017.1.0f3
image

image

image

@EddieRocksUk

This comment has been minimized.

Copy link

commented Nov 29, 2017

GooglePlayGamesPlugin-0.9.42
Unity 2017.2.0f3

error

@usescrt

This comment has been minimized.

Copy link

commented Dec 6, 2017

My guess is, you put the main camera in button iu on click. If you call the script GameObject instead, it will not give an error.

I hope that helped.

@EddieRocksUk

This comment has been minimized.

Copy link

commented Dec 7, 2017

Following an idea on another thread I moved my project to C:\ which 'solved' the error though I don't understand why.
My main camera follows a ball triggered on a panel 'drag' - Event Trigger Pointer Down then Pointer Up

@dandepeched

This comment has been minimized.

Copy link

commented Dec 13, 2017

Same issue with the same versions. No previous versions of "play-games-plugin-for-unity" plugin was installed for this project.

@guplem

This comment has been minimized.

Copy link

commented Dec 13, 2017

I'm in the same situation but my issue is solver by rebooting Unity...

@harshilsavaliya

This comment has been minimized.

Copy link

commented Dec 19, 2017

facing same issue.
Can anybody tell me what to do?
My project is almost ready except this error.

@PathToLife

This comment has been minimized.

Copy link

commented Dec 19, 2017

Sometimes when you restart unity it goes away.

@Yigityakut

This comment has been minimized.

Copy link

commented Dec 27, 2017

Same issue here and i believe that is why i am stuck at trying to make gpg work for weeks!
Can any of you login to your games while you have this error ? It doesn't prevent me from compiling and playing but I believe this is why my GPG is not working.

Please help

Here is the full message

NullReferenceException: Object reference not set to an instance of an object
UnityEditor.InspectorWindow.OnSelectionChange () (at C:/buildslave/unity/build/Editor/Mono/Inspector/InspectorWindow.cs:147)
System.Reflection.MonoMethod.Invoke (System.Object obj, BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) (at /Users/builduser/buildslave/mono/build/mcs/class/corlib/System.Reflection/MonoMethod.cs:222)
Rethrow as TargetInvocationException: Exception has been thrown by the target of an invocation.
System.Reflection.MonoMethod.Invoke (System.Object obj, BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) (at /Users/builduser/buildslave/mono/build/mcs/class/corlib/System.Reflection/MonoMethod.cs:232)
System.Reflection.MethodBase.Invoke (System.Object obj, System.Object[] parameters) (at /Users/builduser/buildslave/mono/build/mcs/class/corlib/System.Reflection/MethodBase.cs:115)
UnityEditor.HostView.Invoke (System.String methodName, System.Object obj) (at C:/buildslave/unity/build/Editor/Mono/HostView.cs:295)
UnityEditor.HostView.Invoke (System.String methodName) (at C:/buildslave/unity/build/Editor/Mono/HostView.cs:288)
UnityEditor.HostView.OnSelectionChange () (at C:/buildslave/unity/build/Editor/Mono/HostView.cs:168)
UnityEditor.AssetDatabase:Refresh()
GooglePlayGames.Editor.GPGSUpgrader:.cctor() (at Assets/GooglePlayGames/Editor/GPGSUpgrader.cs:114)
UnityEditor.EditorAssemblies:ProcessInitializeOnLoadAttributes()

@GieziJo

This comment has been minimized.

Copy link
Author

commented Dec 27, 2017

@Yigityakut I still have the issue, nothing changed, but it does not affect my ability to access GPG.
Everything works fine, the issue is mostly cosmetics for me.

@Yigityakut

This comment has been minimized.

Copy link

commented Dec 27, 2017

@TheGiezi Thank you for your answer. I realized that these are not related because after 2 3 restarts to the unity, it disappeared for now. Everything in my game is ready and I cant release it because of a stupid leaderboard for more than a month. I am stuck. Appreciate the help though.

@jidekrm

This comment has been minimized.

Copy link

commented Jan 4, 2018

@Yigityakut Try comment out the call to AssetDatabase.Refresh in GPGSUpgrader safely. It worked for me. Got the idea from this link.. #1433

@Antonz0

This comment has been minimized.

Copy link
Contributor

commented Jan 17, 2018

@jidekrm A bit more nice way is to add check if (!EditorApplication.isPlayingOrWillChangePlaymode) before AssetDatabase.Refresh() call, because thsi annoying thing happens when you start playmode. Don't know when this property was introduced, though...

@PathToLife

This comment has been minimized.

Copy link

commented Jan 17, 2018

AssetDatabase is a Unity Class.
It just so happens that Google tells it to go looking for asset changes and 'refresh'
https://docs.unity3d.com/ScriptReference/AssetDatabase.Refresh.html

Some time down the refresh process unity sometimes finds some asset with a null ref and throw this. It's got nothing to do with GPGS.

I vote for a engineer from google to put the reason below for why they call AssetDatabase.refresh and close this request.

Don't see anything that could be done on google's side.. except stop calling this taxing refresh..
I really think shouldn't be AssetDB.Refresh() shouldn't be called often.

@cyraid

This comment has been minimized.

Copy link

commented Jul 31, 2019

I'm getting a NullReferenceException "UnityEditor.GameObjectInspector.ClearPreviewCache ()" after using PlayGameServices too. Happens on every run. Using Unity 2019.2.0f1

Edit: As Antonz0 was mentioning, you could probably even stick EditorApplication.isPlayingOrWillChangePlaymode at the top with a return. Because it's an "InitializeOnLoad", and that's getting called on play mode, which wouldn't make sense for the upgrader to run anyway.

So stick:

if (EditorApplication.isPlayingOrWillChangePlaymode)
  return;

At the top of the static constructor GPGSUpgrader() and call it a day.

Edit: Although it still doesn't stop the random NRE's during script compile.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
You can’t perform that action at this time.