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

"Failed to load the HMSGameServiceSettings. Please restart Unity Editor." It happens in v2.3.8, worked in v2.3.7 #504

Open
lxwgogogo opened this issue Jul 17, 2024 · 11 comments · Fixed by #512
Assignees
Labels
details requested Details requested for the issue investigating We are investigating the current problem new waiting for confirmation The solution has been given

Comments

@lxwgogogo
Copy link

Describe the bug & problem
The v2.3.7 works well on my phone. But after I upgrade to v2.3.8, it throws error:

A scripted object (script unknown or not yet loaded) has a different serialization layout when loading. (Read 56 bytes but expected 64 bytes)
Did you #ifdef UNITY_EDITOR a section of your serialized properties in any of your scripts?

I debugged and found the ScriptableHelper.Load has var asset = Resources.Load<T>(filename); which the asset is null. I wonder if I should copy the Assets/Huawei/Settings/Resources folder to my Assets/Resources folder?

Copy link

Thank you for reporting this issue/advice.

We will get back to you as soon as possible.
Would you like to star our plugin to support us? ✨

@lxwgogogo
Copy link
Author

Let me answer to myself. After I copy the Assets/Huawei/Settings/Resources folder to my Assets/Resources folder?, now it works. Is this a required step after the upgrade to v2.3.8?

@Andronovo-bit
Copy link
Collaborator

Andronovo-bit commented Jul 17, 2024

Hello, @lxwgogogo , We tried the game service and didn't faced any errors like the ones you're getting with the settings.

Actually setting's file path is right. It needs to be in Huawei > Settings > Resources.

Maybe, this error is one shot. Can you tell us which Unity version you are using?

Just try this;
Rollback last changes that about settings path and then make Assets > Import All in Unity. Open again and run your project.

@lxwgogogo
Copy link
Author

I am using 2022.3.14f1

@Andronovo-bit
Copy link
Collaborator

The Unity plugin has automatically created its own settings file in "Huawei > Settings > Resources."

image

Can you check again this folder ?

The plugin already won't use files that you copied in "Assets/Resources.". You can delete them.

@Andronovo-bit Andronovo-bit added investigating We are investigating the current problem details requested Details requested for the issue labels Jul 18, 2024
@Andronovo-bit Andronovo-bit added the waiting for confirmation The solution has been given label Aug 2, 2024
@qinhanlei
Copy link
Contributor

I also encountered this issue once.
When I ran git clean -fdx in my project and then reopened Unity 2022.3.39f1, the issue disappeared.
Still don't know why.

@amatveev
Copy link

amatveev commented Aug 2, 2024

i have same error in android build Unity 2022.3.39f1

A scripted object (script unknown or not yet loaded) has a different serialization layout when loading. (Read 52 bytes but expected 60 bytes)
Did you #ifdef UNITY_EDITOR a section of your serialized properties in any of your scripts?

UnityEngine.Resources:Load(String)
HmsPlugin.ScriptableHelper:Load(String, String)
HmsPlugin.HMSIAPKitSettings:.ctor()
System.Activator:CreateInstance()
HmsPlugin.HMSEditorSingleton`1:get_Instance()
HmsPlugin.HMSIAPManager:InitControlOfIAP()
HuaweiMobileServices.Utils.HMSDispatcher:InvokeAsync(Action)
System.Lazy`1:CreateValue()
Gameplay.Billing.Factories.Android.Huawei.ControllerFactory:Create(IAuthTokenSource, IGame, BillingEvents, CurrencyConverter)
.....

@Andronovo-bit
Copy link
Collaborator

Andronovo-bit commented Aug 2, 2024

@amatveev Can you try other Unity version ?

We tried 2022.3.18f1, and we didn't face any errors that you faced.

In the meantime, we will try the Unity version that you used. After that, let's we compare results together.

@amatveev
Copy link

amatveev commented Aug 2, 2024

@amatveev Can you try other Unity version ?

We tried 2022.3.18f1, and we didn't face any errors that you faced.

In the meantime, we will try the Unity version that you used. After that, let's we compare results together.

We upgrade project from 2020.3.41f1 to 2022.3.39f1.
After unity editor upgrade we are upgrade hms-unity-plugin 2.3.4 -> 2.3.8 and 2.3.8 + 2020.3.41f1 work fine

summary:
2.3.8 + 2020.3.41f1 - ok
2.3.8 + 2022.3.39f1 - error
2.3.8 + 2022.3.40f1 - error

A scripted object (script unknown or not yet loaded) has a different serialization layout when loading. (Read 52 bytes but expected 60 bytes)
Did you #ifdef UNITY_EDITOR a section of your serialized properties in any of your scripts?

UnityEngine.Resources:Load(String)
HmsPlugin.ScriptableHelper:Load(String, String)
HmsPlugin.HMSIAPKitSettings:.ctor()
System.Activator:CreateInstance()
HmsPlugin.HMSEditorSingleton`1:get_Instance()
HmsPlugin.HMSIAPManager:InitControlOfIAP()
HuaweiMobileServices.Utils.HMSDispatcher:InvokeAsync(Action)
System.Lazy`1:CreateValue()
Gameplay.Billing.Factories.Android.Huawei.ControllerFactory:Create(IAuthTokenSource, IGame, BillingEvents, CurrencyConverter)

hms-unity-p-2 3 8

@qinhanlei
Copy link
Contributor

@Andronovo-bit @amatveev
I encountered this issue again.
Our project uses version 2022.3.39f1, and the issue disappears upon restarting Unity.
It seems to be a bug in Unity that occurs when something is cached during multiple builds.

@Andronovo-bit
Copy link
Collaborator

Andronovo-bit commented Aug 7, 2024

@amatveev @qinhanlei

We tested this scenario in Unity 2022.3.40f1, but we did not receive any errors similar to yours.

  1. You should never modify the settings file manually. This file has a format.

  2. If you have rarely encountered this error, you can;

    • Go to Assets > Reimport All in the Unity Editor.
  3. If second solution don't solve your problem, you can;

    • Close Unity.
    • Delete the Library folder in your project directory (this folder will be recreated when you reopen the project).
    • Reopen Unity and let it recompile everything.
  4. As a final step, if your problem persists, could you replace the following code in the ScriptableHelper.cs file?


Could you send the HMSIAPKitSettings.asset file that causes an error in Settings/Resources? @amatveev

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
details requested Details requested for the issue investigating We are investigating the current problem new waiting for confirmation The solution has been given
Projects
None yet
4 participants