Unity 4.1.0 PEW EOS Plugin - Unable to find a constructor when launched in build

Hi,

Upgrading our project to the 4.1.0 (from 3.3.1) version of the PEW Unity EOS plugin. All implemented features working with 3.3.1 for EGS and Steam auth (as well as DevAuth in Editor)

Testing in editor sing the DevAuthTool and we have things working as intended, client auths, can access the leaderboard data. Created a build to test the Steam auth side and it is failing to deserialize the configuration files once init has complete:

Unable to populate object of type "PlayEveryWare.EpicOnlineServices.Config" from JSON: "{
  "LogCategoryLevelPairs": [
  {"Category": "Core", "Level": "Info"},
  {"Category": "Auth", "Level": "Info"},
  {"Category": "Friends", "Level": "Info"},
  {"Category": "Presence", "Level": "Info"},
  {"Category": "UserInfo", "Level": "Info"},
  {"Category": "HttpSerialization", "Level": "Info"},
  {"Category": "Ecom", "Level": "Info"},
  {"Category": "P2P", "Level": "Info"},
  {"Category": "Sessions", "Level": "Info"},
  {"Category": "RateLimiter", "Level": "Info"},
  {"Category": "PlayerDataStorage", "Level": "Info"},
  {"Category": "Analytics", "Level": "Info"},
  {"Category": "Messaging", "Level": "Info"},
  {"Category": "Connect", "Level": "Info"},
  {"Category": "Overlay", "Level": "Info"},
  {"Category": "Achievements", "Level": "Info"},
  {"Category": "Stats", "Level": "Info"},
  {"Category": "Ui", "Level": "Info"},
  {"Category": "Lobby", "Level": "Info"},
  {"Category": "Leaderboards", "Level": "Info"},
  {"Category": "Keychain", "Level": "Info"},
  {"Category": "IntegratedPlatform", "Level": "Info"},
  {"Category": "TitleStorage", "Level": "Info"},
  {"Category": "Mods", "Level": "Info"},
  {"Category": "AntiCheat", "Level": "Info"},
  {"Category": "Reports", "Level": "Info"},
  {"Category": "Sanctions", "Level": "Info"},
  {"Category": "ProgressionSnapshots", "Level": "Info"},
  {"Category": "Kws", "Level": "Info"},
  {"Category": "RTCAdmin", "Level": "Info"},
  {"Category": "CustomInvites", "Level": "Info"},
  {"Category": "AllCategories", "Level": "Info"}
  ]
}". Exception: "Unable to find a constructor to use for type PlayEveryWare.EpicOnlineServices.LogCategoryLevelPair. A class should either have a default constructor, one constructor with arguments or a constructor marked with the JsonConstructor attribute. Path 'LogCategoryLevelPairs[0].Category', line 3, position 13."
UnityEngine.StackTraceUtility:ExtractStackTrace () (at C:/build/output/unity/unity/Runtime/Export/Scripting/StackTrace.cs:37)
UnityEngine.DebugLogHandler:LogFormat (UnityEngine.LogType,UnityEngine.Object,string,object[])
UnityEngine.Logger:Log (UnityEngine.LogType,object)
UnityEngine.Debug:LogError (object)
PlayEveryWare.EpicOnlineServices.Utility.JsonUtility:FromJsonOverwrite<PlayEveryWare.EpicOnlineServices.Config> (string,PlayEveryWare.EpicOnlineServices.Config) (at ./Library/PackageCache/com.playeveryware.eos@ee66b0f0ac4e/Runtime/Core/Utility/JsonUtility.cs:165)
PlayEveryWare.EpicOnlineServices.Config:Read () (at ./Library/PackageCache/com.playeveryware.eos@ee66b0f0ac4e/Runtime/Core/Config/Config.cs:447)
PlayEveryWare.EpicOnlineServices.Config:Get<PlayEveryWare.EpicOnlineServices.LogLevelConfig> () (at ./Library/PackageCache/com.playeveryware.eos@ee66b0f0ac4e/Runtime/Core/Config/Config.cs:386)
PlayEveryWare.EpicOnlineServices.Utility.LogLevelUtility:get_LogLevelList () (at ./Library/PackageCache/com.playeveryware.eos@ee66b0f0ac4e/Runtime/Core/Utility/LogLevelUtility.cs:52)
PlayEveryWare.EpicOnlineServices.EOSManager/EOSSingleton:InitializeLogLevels () (at ./Library/PackageCache/com.playeveryware.eos@ee66b0f0ac4e/Runtime/Core/EOSManager.cs:782)
PlayEveryWare.EpicOnlineServices.EOSManager/EOSSingleton:Init (PlayEveryWare.EpicOnlineServices.IEOSCoroutineOwner,string) (at ./Library/PackageCache/com.playeveryware.eos@ee66b0f0ac4e/Runtime/Core/EOSManager.cs:604)
PlayEveryWare.EpicOnlineServices.EOSManager:Awake () (at ./Library/PackageCache/com.playeveryware.eos@ee66b0f0ac4e/Runtime/Core/EOSManager.cs:1871)
UnityEngine.GameObject:AddComponent (System.Type) (at C:/build/output/unity/unity/Runtime/Export/Scripting/GameObject.bindings.cs:240)
UnityEngine.GameObject:AddComponent<PlayEveryWare.EpicOnlineServices.EOSManager> () (at C:/build/output/unity/unity/Runtime/Export/Scripting/GameObject.bindings.cs:245)

Same happens for the Platform config right after.

This does not happen when running in editor, Is there some setup code I need to force to run ahead of this? Possibly something to force the `LogCategoryLevelPair` class to register its factory?

Our own code uses the

[RuntimeInitializeOnLoadMethod(RuntimeInitializeLoadType.BeforeSceneLoad)]

mechanism to start its StartOfWorld, which does cause a Race Condition with some parts of the EOS Plugin setup, I have already moved portions of the init to be delayed a frame or two to accomodate this, is there something else that is possibly not quite there yet?

Hello!

I was also encountering this!

My solution was to turn down the “Managed Stripping Level” in the Unity Player Settings under Optimization.

Otherwise, would have to make source code changes to the plugin and add the attribute [UnityEngine.Scripting.Preserve] to anything that Newtonsoft Json is complaining doesn’t exist, like some derived Config class constructors in the EOS plugin’s case.

Thanks for the information about your solution. We have a planned fix for preventing the stripping of the Newtonsoft Json in a future release.

Perfect! Thank you so much! Had completely forgotten it did stripping! (It was set to minimal too!) disabled it and all happy.

I am using FullSerializer myself and was considering that maybe there was a werid conflict.

Hopefully the devs will see this and make the changes you suggest as that sounds the cleanest way.

Thanks again.