NullReferenceException: Object reference not set to an instance of an objectUnityEditor.InspectorWindow.OnSelectionChange 에러 수정

GooglePlayGames를 유니티에 심다보면 에디터에서 실행하면 이런 에러가 뜬다.

에디터에서만 뜨는 에러지만 그래도 빨간 에러는 기분이 나쁘다.

아래의 에러에서

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()

요놈이 문제다
GooglePlayGames.Editor.GPGSUpgrader:.cctor() (at Assets/GooglePlayGames/Editor/GPGSUpgrader.cs:114)

그럼 저 스크립트로 찾아가서 해당 줄을 보면
달랑
AssetDatabase.Refresh();
이 코드만 있다.

이것을

if (!EditorApplication.isPlayingOrWillChangePlaymode)
{
AssetDatabase.Refresh();
}

이렇게 수정해주면 에러가 안난다.

이 글을 공유하기

댓글

Designed by JB FACTORY