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

Async loading cause "JsonReaderException: Unexpected character encountered while parsing value: g. Path '', line 0, position 0." #224

Open
SwatiScorpbit opened this issue Oct 27, 2022 · 0 comments

Comments

@SwatiScorpbit
Copy link

Hey,
GLB Sync loading is working but when I try Async method it causes "Jason reader exception", here is the full script:

private void Update()
{
    if (Input.GetKey(KeyCode.L))
    {
        ImportGLTFAsync(gltfFileLocation);
    }
}

[ContextMenu("Import GLTF")]
void ImportGLTFSync()
{
    loadedGameObject = Importer.LoadFromFile(gltfFileLocation);
    RotatingObject rotatingObject = loadedGameObject.AddComponent<RotatingObject>();
    rotatingObject.target = loadedGameObject.transform;
    rotatingObject.roationSpeed = 15f;
}

void ImportGLTFAsync(string filepath)
{
    Importer.ImportGLTFAsync(filepath, new ImportSettings(), OnFinishAsync);
}

private void OnFinishAsync(GameObject arg1, AnimationClip[] arg2)
{
    Debug.Log("Finished importing " + arg1.name);
}

Error Log:
JsonReaderException: Unexpected character encountered while parsing value: g. Path '', line 0, position 0.
Newtonsoft.Json.JsonTextReader.ParseValue () (at /root/repo/Src/Newtonsoft.Json/JsonTextReader.cs:1817)
Newtonsoft.Json.JsonTextReader.Read () (at /root/repo/Src/Newtonsoft.Json/JsonTextReader.cs:429)
Newtonsoft.Json.JsonReader.ReadAndMoveToContent () (at /root/repo/Src/Newtonsoft.Json/JsonReader.cs:1240)
Newtonsoft.Json.JsonReader.ReadForType (Newtonsoft.Json.Serialization.JsonContract contract, System.Boolean hasConverter) (at /root/repo/Src/Newtonsoft.Json/JsonReader.cs:1197)
Newtonsoft.Json.Serialization.JsonSerializerInternalReader.Deserialize (Newtonsoft.Json.JsonReader reader, System.Type objectType, System.Boolean checkAdditionalContent) (at /root/repo/Src/Newtonsoft.Json/Serialization/JsonSerializerInternalReader.cs:202)
Newtonsoft.Json.JsonSerializer.DeserializeInternal (Newtonsoft.Json.JsonReader reader, System.Type objectType) (at /root/repo/Src/Newtonsoft.Json/JsonSerializer.cs:904)
Newtonsoft.Json.JsonSerializer.Deserialize (Newtonsoft.Json.JsonReader reader, System.Type objectType) (at /root/repo/Src/Newtonsoft.Json/JsonSerializer.cs:883)
Newtonsoft.Json.JsonConvert.DeserializeObject (System.String value, System.Type type, Newtonsoft.Json.JsonSerializerSettings settings) (at /root/repo/Src/Newtonsoft.Json/JsonConvert.cs:831)
Newtonsoft.Json.JsonConvert.DeserializeObject[T] (System.String value, Newtonsoft.Json.JsonSerializerSettings settings) (at /root/repo/Src/Newtonsoft.Json/JsonConvert.cs:787)
Newtonsoft.Json.JsonConvert.DeserializeObject[T] (System.String value) (at /root/repo/Src/Newtonsoft.Json/JsonConvert.cs:720)
Siccity.GLTFUtility.Importer+<>c__DisplayClass16_0.b__0 () (at Library/PackageCache/com.siccity.gltfutility@ac70aeb919/Scripts/Importer.cs:286)
System.Threading.Tasks.Task1[TResult].InnerInvoke () (at <9aad1b3a47484d63ba2b3985692d80e9>:0) System.Threading.Tasks.Task.Execute () (at <9aad1b3a47484d63ba2b3985692d80e9>:0) Rethrow as AggregateException: One or more errors occurred. (Unexpected character encountered while parsing value: g. Path '', line 0, position 0.) System.Threading.Tasks.Task.ThrowIfExceptional (System.Boolean includeTaskCanceledExceptions) (at <9aad1b3a47484d63ba2b3985692d80e9>:0) System.Threading.Tasks.Task1[TResult].GetResultCore (System.Boolean waitCompletionNotification) (at <9aad1b3a47484d63ba2b3985692d80e9>:0)
System.Threading.Tasks.Task`1[TResult].get_Result () (at <9aad1b3a47484d63ba2b3985692d80e9>:0)
Siccity.GLTFUtility.Importer+d__16.MoveNext () (at Library/PackageCache/com.siccity.gltfutility@ac70aeb919/Scripts/Importer.cs:289)
UnityEngine.SetupCoroutine.InvokeMoveNext (System.Collections.IEnumerator enumerator, System.IntPtr returnValueAddress) (at <86acb61e0d2b4b36bc20af11093be9a5>:0)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant