StartCoroutine_Auto_Internal can only be called from the main thread.
Im my app , I am using PlayFab API , and this code is called from many places
PlayFabClientAPI.UpdateUserData(userDataRequest, (result1) => { Debug.Log("Data updated successfull "+result1.CustomData); }, (error1) => { Debug.Log("Data update error " + error1.ErrorMessage); }, null); } catch(Exception e) { Debug.Log (" error in update user data :" + e.ToString ()); }
but at a particular call i get this error
03-20 21:32:40.393 8565-9404/com.delusion.ludofun E/Unity: StartCoroutine_Auto_Internal can only be called from the main thread.
Constructors and field initializers will be executed from the loading thread when loading a scene.
Don't use this function in the constructor or field initializers, instead move initialization code to the Awake or Start function.
Stacktrace is not supported on this platform.
(Filename: /Users/builduser/buildslave/unity/build/Runtime/Scripting/ScriptingThreadAndSerializationSafeCheck.cpp Line: 81)
03-20 21:32:40.403 8565-8565/com.delusion.ludofun D/ActivityThread: ACT-PAUSE_ACTIVITY_FINISHING handled : 0 / android.os.BinderProxy@21927417
03-20 21:32:40.409 8565-9404/com.delusion.ludofun I/Unity: error in update user data :UnityEngine.UnityException: StartCoroutine_Auto_Internal can only be called from the main thread.
Constructors and field initializers will be executed from the loading thread when loading a scene.
Don't use this function in the constructor or field initializers, instead move initialization code to the Awake or Start function.
at UnityEngine.MonoBehaviour.StartCoroutine (IEnumerator routine) [0x00003] in /Users/builduser/buildslave/unity/build/artifacts/generated/common/runtime/MonoBehaviourBindings.gen.cs:62
at PlayFab.Internal.PlayFabHTTP.Post (System.String urlPath, System.String data, System.String authType, System.String authKey, System.Action`1 callback, System.Object request, System.Object customData) [0x000b7] in /Users/swatiagarwal/Desktop/Unity/Ludo Online/Ludo Online/Assets/PlayFabSDK/Internal/PlayFabHTTP.cs:66
at PlayFab.PlayFabClientAPI.UpdateUserData (PlayFab.ClientModels.UpdateUserDataRequest request, PlayFab.ProcessApiCallback`1 resultCallback, PlayFab.Error
I am unable to understand what wrong could have been done in my code.
Comment