Mixedrealitytoolkit-unity: Can't build solution due to Field Serialization Error

Created on 16 Aug 2017  路  13Comments  路  Source: microsoft/MixedRealityToolkit-Unity

Hello!

I tried to update the Toolkit from a old version which used unity 5.5.2f1 to the current release tagged v1.2017.1.0.

Whenever I try to create the sln (unity version 2017.1.0f3) using the HoloToolkit -> Build Window -> Build SLN, Build APPX Button I get the following errors:

Type '[Assembly-CSharp]HoloToolkit.Unity.InputModule.HandGuidance' has an extra field 'Cursor' of type 'UnityEngine.GameObject' in the player and thus can't be serialized 
UnityEditor.BuildPipeline:BuildPlayer(String[], String, BuildTarget, BuildOptions)
HoloToolkit.Unity.BuildSLNUtilities:PerformBuild(BuildInfo) (at Assets/HoloToolkit/Build/Editor/BuildSLNUtilities.cs:145)
HoloToolkit.Unity.BuildDeployTools:BuildSLN(String, Boolean) (at Assets/HoloToolkit/Build/Editor/BuildDeployTools.cs:67)
HoloToolkit.Unity.<OnGUI>c__AnonStorey0:<>m__2() (at Assets/HoloToolkit/Build/Editor/BuildDeployWindow.cs:273)
UnityEditor.EditorApplication:Internal_CallDelayFunctions()

----

Type '[Assembly-CSharp]HoloToolkit.Unity.InputModule.HandGuidance' has an extra field 'HandGuidanceIndicator' of type 'UnityEngine.GameObject' in the player and thus can't be serialized 
UnityEditor.BuildPipeline:BuildPlayer(String[], String, BuildTarget, BuildOptions)
HoloToolkit.Unity.BuildSLNUtilities:PerformBuild(BuildInfo) (at Assets/HoloToolkit/Build/Editor/BuildSLNUtilities.cs:145)
HoloToolkit.Unity.BuildDeployTools:BuildSLN(String, Boolean) (at Assets/HoloToolkit/Build/Editor/BuildDeployTools.cs:67)
HoloToolkit.Unity.<OnGUI>c__AnonStorey0:<>m__2() (at Assets/HoloToolkit/Build/Editor/BuildDeployWindow.cs:273)
UnityEditor.EditorApplication:Internal_CallDelayFunctions()

----

Type '[Assembly-CSharp]HoloToolkit.Unity.InputModule.HandGuidance' has an extra field 'HandGuidanceThreshold' of type 'System.Single' in the player and thus can't be serialized 
UnityEditor.BuildPipeline:BuildPlayer(String[], String, BuildTarget, BuildOptions)
HoloToolkit.Unity.BuildSLNUtilities:PerformBuild(BuildInfo) (at Assets/HoloToolkit/Build/Editor/BuildSLNUtilities.cs:145)
HoloToolkit.Unity.BuildDeployTools:BuildSLN(String, Boolean) (at Assets/HoloToolkit/Build/Editor/BuildDeployTools.cs:67)
HoloToolkit.Unity.<OnGUI>c__AnonStorey0:<>m__2() (at Assets/HoloToolkit/Build/Editor/BuildDeployWindow.cs:273)
UnityEditor.EditorApplication:Internal_CallDelayFunctions()

----

Fields serialized in Editor, class 'HoloToolkit.Unity.InputModule.HandGuidance'

UnityEditor.BuildPipeline:BuildPlayer(String[], String, BuildTarget, BuildOptions)
HoloToolkit.Unity.BuildSLNUtilities:PerformBuild(BuildInfo) (at Assets/HoloToolkit/Build/Editor/BuildSLNUtilities.cs:145)
HoloToolkit.Unity.BuildDeployTools:BuildSLN(String, Boolean) (at Assets/HoloToolkit/Build/Editor/BuildDeployTools.cs:67)
HoloToolkit.Unity.<OnGUI>c__AnonStorey0:<>m__2() (at Assets/HoloToolkit/Build/Editor/BuildDeployWindow.cs:273)
UnityEditor.EditorApplication:Internal_CallDelayFunctions()

----

Fields serialized in target platform, class 'HoloToolkit.Unity.InputModule.HandGuidance'
'Cursor' of type 'UnityEngine.GameObject'
'HandGuidanceIndicator' of type 'UnityEngine.GameObject'
'HandGuidanceThreshold' of type 'System.Single'

UnityEditor.BuildPipeline:BuildPlayer(String[], String, BuildTarget, BuildOptions)
HoloToolkit.Unity.BuildSLNUtilities:PerformBuild(BuildInfo) (at Assets/HoloToolkit/Build/Editor/BuildSLNUtilities.cs:145)
HoloToolkit.Unity.BuildDeployTools:BuildSLN(String, Boolean) (at Assets/HoloToolkit/Build/Editor/BuildDeployTools.cs:67)
HoloToolkit.Unity.<OnGUI>c__AnonStorey0:<>m__2() (at Assets/HoloToolkit/Build/Editor/BuildDeployWindow.cs:273)
UnityEditor.EditorApplication:Internal_CallDelayFunctions()

----

Error building player because script class layout is incompatible between the editor and the player.

I opened the Unity project in the new unity version, deleted the Toolkit directories and reimported the assets.

I can run the project normally inside the editor and everything works there.

Could somebody help, please?

Most helpful comment

I am having this problem when building from the HoloToolkit build window when my platform is set to PC, Mac & Linux Standalone. Going into Build Settings, selecting Universal Windows Platform, and clicking the Switch Platform button seems to fix the problem.

I'm not sure what the bug is here. Possibilities:
1) Not a bug. It is by design that you should switch to UWP platform when developing for HoloLens.
1) Bug in HoloToolkit build window that it isn't fully switching over to the UWP platform in the build that it creates.
1) Bug in HandGuidance.cs that it has different serializable fields on different platforms. #if should be moved after the member variables so that the serialized game object data can be written from Windows platform and read on UWP platform.

All 13 comments

This is strange. Did you save the prefabs so the were reserialized before making the build?

I would also try deleting the whole HTK folder and importing/copying the new one. Unity packages are notorious for keeping around files that should have been removed.

Ah github didn't attach my email as reply, sorry for the late reply.

I've deleted all HTK folders I previously had and then imported the new version.

And I've reverted all HTK prefabs.

Did that fix, or still getting the problem?

Still get the same problem.

Thanks for the update.

I've deleted the HandGuidance.cs script from the HTK\Input\Scripts Folder since I don't need the indicator and now it builds.

I'll close it for now, will reopen if I have more errors like that.

Thanks!

Had the exact same experience. Have also deleted HandGuidance.cs and compiles fine again.

I am having this problem when building from the HoloToolkit build window when my platform is set to PC, Mac & Linux Standalone. Going into Build Settings, selecting Universal Windows Platform, and clicking the Switch Platform button seems to fix the problem.

I'm not sure what the bug is here. Possibilities:
1) Not a bug. It is by design that you should switch to UWP platform when developing for HoloLens.
1) Bug in HoloToolkit build window that it isn't fully switching over to the UWP platform in the build that it creates.
1) Bug in HandGuidance.cs that it has different serializable fields on different platforms. #if should be moved after the member variables so that the serialized game object data can be written from Windows platform and read on UWP platform.

@ForrestTrepte This resolved it for me as well.

I'm almost certain my project was set to build for UWP before upgrading the HoloToolkit, but can't say for sure.

We shouldn't be getting these kinds of errors for other platforms.

What's odd is after switching it back to UWP and then to Standalone, the errors where gone.

  1. Not a bug. It is by design that you should switch to UWP platform when developing for HoloLens.

Def a bug.

  1. Bug in HoloToolkit build window that it isn't fully switching over to the UWP platform in the build that it creates.

Yeah hopefully I fixed this issue in https://github.com/Microsoft/MixedRealityToolkit-Unity/pull/887

  1. Bug in HandGuidance.cs that it has different serializable fields on different platforms. #if should be moved after the member variables so that the serialized game object data can be written from Windows platform and read on UWP platform.

Definitely the issue I think

Got this error today with 2017.3.1f1, changing manually to UWP platform worked.

Was this page helpful?
0 / 5 - 0 ratings