siccity / gltfutility Goto Github PK
View Code? Open in Web Editor NEWSimple GLTF importer for Unity
License: MIT License
Simple GLTF importer for Unity
License: MIT License
A setting to extract the materials to a folder for editing/configuration like with standard Unity 3D formats would be incredibly useful as at the moment, you have to create new materials and assign them to specific objects in order to change material settings.
Hi, I'm getting error on loading .glb file
InvalidOperationException: Nullable object must have a value.
System.Nullable`1[T].get_Value () (at <599589bf4ce248909b8a14cbe4a2034e>:0)
Siccity.GLTFUtility.GLTFAccessor.Import (Siccity.GLTFUtility.GLTFBufferView+ImportResult[] bufferViews) (at Assets/Scripts/Spec/GLTFAccessor.cs:302)
Siccity.GLTFUtility.Importer+<>c__DisplayClass7_0.<LoadInternal>b__2 (Siccity.GLTFUtility.GLTFAccessor x) (at Assets/Scripts/Importer.cs:86)
System.Linq.Enumerable+SelectListIterator`2[TSource,TResult].ToArray () (at <fbb5ed17eb6e46c680000f8910ebb50c>:0)
System.Linq.Enumerable.ToArray[TSource] (System.Collections.Generic.IEnumerable`1[T] source) (at <fbb5ed17eb6e46c680000f8910ebb50c>:0)
Siccity.GLTFUtility.Importer.LoadInternal (Siccity.GLTFUtility.GLTFObject gltfObject, System.String filepath, Siccity.GLTFUtility.ImportSettings importSettings, Siccity.GLTFUtility.GLTFAnimation+ImportResult[]& animations) (at Assets/Scripts/Importer.cs:86)
Siccity.GLTFUtility.Importer.ImportGLB (System.String filepath, Siccity.GLTFUtility.ImportSettings importSettings, Siccity.GLTFUtility.GLTFAnimation+ImportResult[]& animations) (at Assets/Scripts/Importer.cs:60)
Siccity.GLTFUtility.GLBImporter.OnImportAsset (UnityEditor.Experimental.AssetImporters.AssetImportContext ctx) (at Assets/Scripts/Editor/GLBImporter.cs:11)
UnityEditor.Experimental.AssetImporters.ScriptedImporter.GenerateAssetData (UnityEditor.Experimental.AssetImporters.AssetImportContext ctx) (at C:/buildslave/unity/build/Modules/AssetPipelineEditor/Public/ScriptedImporter.cs:22)
if the texture is embeded, or a link to a web address, it fails, this is because it looks for that exact path in assets (so it looks for something like "Assets/http://localhost/test/threejs/images/white.png" or "Assets/data:image/png;base64,[base64 data]" and of course doesn't find either of those things.)
GLTFUtility/Scripts/Spec/GLTFMaterial.cs
Line 171 in d5df3df
Just found an easy bug to squash.
GLTFMaterial.cs Line 171 tries to set the glossiness float value for the specular material, but it's using the wrong string parameter name. It should be '_GlossyReflections' instead of '_Glossiness'.
I'm having an issue with GTLFUtility's runtime importing on the Oculus Quest. Works great on Mac/Windows and I'm loving the lightweight approach vs other GLTF Importer options.
I'm not entirely sure if this is a issue with the package or user error, but figured I'd send up the logs in hopes of some help.
I'm currently building on Windows 10 using Unity 2019.2.9f1
Logs:
AndroidPlayer([email protected]:34999) ArgumentNullException: Value cannot be null.
Parameter name: shader
at (wrapper managed-to-native) UnityEngine.Material.CreateWithShader(UnityEngine.Material,UnityEngine.Shader)
at UnityEngine.Material..ctor (UnityEngine.Shader shader) [0x00009] in /Users/builduser/buildslave/unity/build/Runtime/Export/Shaders/Shader.bindings.cs:118
at Siccity.GLTFUtility.GLTFMaterial+PbrMetalRoughness.CreateMaterial (Siccity.GLTFUtility.GLTFTexture+ImportResult[] textures, Siccity.GLTFUtility.AlphaMode alphaMode, Siccity.GLTFUtility.ShaderSettings shaderSettings) [0x00043] in D:\PROJECTS\git\TestProject\Assets\GLTFUtility\Scripts\Spec\GLTFMaterial.cs:109
at Siccity.GLTFUtility.GLTFMaterial.CreateMaterial (Siccity.GLTFUtility.GLTFTexture+ImportResult[] textures, Siccity.GLTFUtility.ShaderSettings shaderSettings) [0x0000f] in D:\PROJECTS\git\TestProject\Assets\GLTFUtility\Scripts\Spec\GLTFMaterial.cs:39
at Siccity.GLTFUtility.GLTFMaterial+ImportTask.OnMainThreadFinalize () [0x00028] in D:\PROJECTS\git\TestProject\Assets\GLTFUtility\Scripts\Spec\GLTFMaterial.cs:225
at Siccity.GLTFUtility.Importer+ImportTask`1[TReturn].RunSynchronously () [0x0000d] in D:\PROJECTS\git\TestProject\Assets\GLTFUtility\Scripts\Importer.cs:96
at Siccity.GLTFUtility.Importer.LoadInternal (Siccity.GLTFUtility.GLTFObject gltfObject, System.String filepath, Siccity.GLTFUtility.ImportSettings importSettings, Siccity.GLTFUtility.GLTFAnimation+ImportResult[]& animations) [0x00091] in D:\PROJECTS\git\TestProject\Assets\GLTFUtility\Scripts\Importer.cs:138
at Siccity.GLTFUtility.Importer.ImportGLTF (System.String filepath, Siccity.GLTFUtility.ImportSettings importSettings, Siccity.GLTFUtility.GLTFAnimation+ImportResult[]& animations) [0x0000f] in D:\PROJECTS\git\TestProject\Assets\GLTFUtility\Scripts\Importer.cs:77
at Siccity.GLTFUtility.Importer.LoadFromFile (System.String filepath, Siccity.GLTFUtility.ImportSettings importSettings, Siccity.GLTFUtility.GLTFAnimation+ImportResult[]& animations, Siccity.GLTFUtility.Format format) [0x00063] in D:\PROJECTS\git\TestProject\Assets\GLTFUtility\Scripts\Importer.cs:32
at Siccity.GLTFUtility.Importer.LoadFromFile (System.String filepath, Siccity.GLTFUtility.ImportSettings importSettings, Siccity.GLTFUtility.Format format) [0x00001] in D:\PROJECTS\git\TestProject\Assets\GLTFUtility\Scripts\Importer.cs:21
at FileManager.LoadModelWithGLTFUtility (TestNamespace.File file, System.Action`1[T] callback) [0x0003d] in D:\PROJECTS\git\TestProject\Assets\Scripts\Classes\FileManager.cs:67
at TestObject.DownloadModelIfNeeded (TestNamespace.InteractableState state) [0x0005c] in D:\PROJECTS\git\TestProject\Assets\Scripts\TestObject.cs:258
at TestObject.UpdateObject () [0x00070] in D:\PROJECTS\git\TestProject\Assets\Scripts\TestObject.cs:213
at UXSessionManager.UpdateObjectInScene (TestNamespace.BaseData objectData) [0x0008c] in D:\PROJECTS\git\TestProject\Assets\UXFoundation\UXManagers\UXSessionManager.cs:256
at UXSessionManager.ListenForDataUpdate (System.Object value) [0x00008] in D:\PROJECTS\git\TestProject\Assets\UXFoundation\UXManagers\UXSessionManager.cs:222
at UnityEngine.Events.InvokableCall`1[T1].Invoke (T1 args0) [0x00018] in /Users/builduser/buildslave/unity/build/Runtime/Export/UnityEvent/UnityEvent.cs:207
at UnityEngine.Events.UnityEvent`1[T0].Invoke (T0 arg0) [0x00025] in /Users/builduser/buildslave/unity/build/Runtime/Export/UnityEvent/UnityEvent/UnityEvent_1.cs:58
at EventManager.Trigger (System.String eventName, System.Object value) [0x00015] in D:\PROJECTS\git\TestProject\Assets\Scripts\Classes\EventManager.cs:39
at TestNamespace.BaseData.SendUpdate () [0x00001] in D:\PROJECTS\git\TestProject\Assets\Scripts\Classes\Data\BaseData.cs:60
at UXSession.CreateDownloadedObject (TestNamespace.File file, System.String type) [0x000c2] in D:\PROJECTS\git\TestProject\Assets\UXFoundation\UXData\UXSession.cs:100
at ObjectsController+<>c__DisplayClass10_2.<OnEnable>b__0 () [0x00001] in D:\PROJECTS\git\TestProject\Assets\Scripts\UI\Controllers\ObjectsController.cs:149
at UnityEngine.Events.InvokableCall.Invoke () [0x00017] in /Users/builduser/buildslave/unity/build/Runtime/Export/UnityEvent/UnityEvent.cs:166
at UnityEngine.Events.UnityEvent.Invoke () [0x00024] in /Users/builduser/buildslave/unity/build/Runtime/Export/UnityEvent/UnityEvent/UnityEvent_0.cs:58
at UnityEngine.UI.Button.Press () [0x00027] in D:\Unity\2019.2.9f1\Editor\Data\Resources\PackageManager\BuiltInPackages\com.unity.ugui\Runtime\UI\Core\Button.cs:68
at UnityEngine.UI.Button.OnPointerClick (UnityEngine.EventSystems.PointerEventData eventData) [0x00010] in D:\Unity\2019.2.9f1\Editor\Data\Resources\PackageManager\BuiltInPackages\com.unity.ugui\Runtime\UI\Core\Button.cs:110
at UnityEngine.EventSystems.ExecuteEvents.Execute (UnityEngine.EventSystems.IPointerClickHandler handler, UnityEngine.EventSystems.BaseEventData eventData) [0x00001] in D:\Unity\2019.2.9f1\Editor\Data\Resources\PackageManager\BuiltInPackages\com.unity.ugui\Runtime\EventSystem\ExecuteEvents.cs:50
at UnityEngine.EventSystems.ExecuteEvents.Execute[T] (UnityEngine.GameObject target, UnityEngine.EventSystems.BaseEventData eventData, UnityEngine.EventSystems.ExecuteEvents+EventFunction`1[T1] functor) [0x0006c] in D:\Unity\2019.2.9f1\Editor\Data\Resources\PackageManager\BuiltInPackages\com.unity.ugui\Runtime\EventSystem\ExecuteEvents.cs:261
UnityEngine.DebugLogHandler:Internal_LogException(Exception, Object)
UnityEngine.DebugLogHandler:LogException(Exception, Object)
UnityEngine.Logger:LogException(Exception, Object)
UnityEngine.Debug:LogException(Exception)
UnityEngine.EventSystems.ExecuteEvents:Execute(GameObject, BaseEventData, EventFunction`1) (at D:\Unity\2019.2.9f1\Editor\Data\Resources\PackageManager\BuiltInPackages\com.unity.ugui\Runtime\EventSystem\ExecuteEvents.cs:265)
VRPointerInputModule:ProcessRelease(PointerEventData) (at D:\PROJECTS\git\TestProject\Assets\Scripts\VRPointerInputModule.cs:175)
VRPointerInputModule:Process() (at D:\PROJECTS\git\TestProject\Assets\Scripts\VRPointerInputModule.cs:86)
UnityEngine.EventSystems.EventSystem:Update() (at D:\Unity\2019.2.9f1\Editor\Data\Resources\PackageManager\BuiltInPackages\com.unity.ugui\Runtime\EventSystem\EventSystem.cs:377)
(Filename: /Users/builduser/buildslave/unity/build/Runtime/Export/Shaders/Shader.bindings.cs Line: 118)
Solution:
Just add a preserved default constructor to all classes that are json serialized.
Example:
[Preserve]
public GLTFObject(){}
Rigs stopped working after introducing multiple submeshes in 1c603c3
Originally requested by @umresh in #26 (comment)
With other imported models, you can filter them in the Unity "Project" menu's searchbar using "t:model" for the full model and "t:mesh" for the individual meshes inside the model. Being able to do that here would be amazing for quick searching.
Some parts of the model are not rendered correctly in the editor as well as on the end device only at certain camera positions.
I suspect that this is due to the render queue of transparent materials.
If I include GLTFUtiliy as .unitypackage in my project, the import module is not available to me, so the GLTF shaders are not used and the model is displayed correctly.
As soon as I add GLTFUtiliy to the package.json file, the import window is available to me and the corresponding shaders are used.
Hi,
I am using this GLTF for first time and GLTFUtility looks more promising than UnityGLTF. But when I downloaded unitypackage, I am unable to use it in project. May be a small documentation on how to use will help
Hi!
First of all, thanks for this great plugin. I haven't found any documentation about iOS support (yet) and when building to an iOS device, I encountered the following error concerning a parameterless constructor in XCode:
JsonException: No parameterless constructor defined for 'Siccity.GLTFUtility.Converters.TranslationConverter'.
at Newtonsoft.Json.Serialization.JsonTypeReflector+<>c__DisplayClass22_0.<GetCreator>b__0 (System.Object[] parameters) [0x00000] in <00000000000000000000000000000000>:0
at System.Func`2[T,TResult].Invoke (T arg) [0x00000] in <00000000000000000000000000000000>:0
at Newtonsoft.Json.Serialization.JsonTypeReflector.GetJsonConverter (System.Object attributeProvider) [0x00000] in <00000000000000000000000000000000>:0
at Newtonsoft.Json.Serialization.DefaultContractResolver.SetPropertySettingsFromAttributes (Newtonsoft.Json.Serialization.JsonProperty property, System.Object attributeProvider, System.String name, System.Type declaringType, Newtonsoft.Json.MemberSerialization memberSerialization, System.Boolean& allowNonPublicAccess) [0x00000] in <00000000000000000000000000000000>:0
at Newtonsoft.Json.Serialization.DefaultContractResolver.CreateProperty (System.Reflection.MemberInfo member, Newtonsoft.Json.MemberSerialization memberSerialization) [0x00000] in <00000000000000000000000000000000>:0
at Newtonsoft.Json.Serialization.DefaultContractResolver.CreateProperties (System.Type type, Newtonsoft.Json.MemberSerialization memberSerialization) [0x00000] in <00000000000000000000000000000000>:0
at Newtonsoft.Json.Serialization.DefaultContractResolver.CreateObjectContract (System.Type objectType) [0x00000] in <00000000000000000000000000000000>:0
at System.Func`2[T,TResult].Invoke (T arg) [0x00000] in <00000000000000000000000000000000>:0
at System.Collections.Concurrent.ConcurrentDictionary`2[TKey,TValue].GetOrAdd (TKey key, System.Func`2[T,TResult] valueFactory) [0x00000] in <00000000000000000000000000000000>:0
at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.PopulateList (System.Collections.IList list, Newtonsoft.Json.JsonReader reader, Newtonsoft.Json.Serialization.JsonArrayContract contract, Newtonsoft.Json.Serialization.JsonProperty containerProperty, System.String id) [0x00000] in <00000000000000000000000000000000>:0
at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateList (Newtonsoft.Json.JsonReader reader, System.Type objectType, Newtonsoft.Json.Serialization.JsonContract contract, Newtonsoft.Json.Serialization.JsonProperty member, System.Object existingValue, System.String id) [0x00000] in <00000000000000000000000000000000>:0
at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateValueInternal (Newtonsoft.Json.JsonReader reader, System.Type objectType, Newtonsoft.Json.Serialization.JsonContract contract, Newtonsoft.Json.Serialization.JsonProperty member, Newtonsoft.Json.Serialization.JsonContainerContract containerContract, Newtonsoft.Json.Serialization.JsonProperty containerMember, System.Object existingValue) [0x00000] in <00000000000000000000000000000000>:0
at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.SetPropertyValue (Newtonsoft.Json.Serialization.JsonProperty property, Newtonsoft.Json.JsonConverter propertyConverter, Newtonsoft.Json.Serialization.JsonContainerContract containerContract, Newtonsoft.Json.Serialization.JsonProperty containerProperty, Newtonsoft.Json.JsonReader reader, System.Object target) [0x00000] in <00000000000000000000000000000000>:0
at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.PopulateObject (System.Object newObject, Newtonsoft.Json.JsonReader reader, Newtonsoft.Json.Serialization.JsonObjectContract contract, Newtonsoft.Json.Serialization.JsonProperty member, System.String id) [0x00000] in <00000000000000000000000000000000>:0
at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateObject (Newtonsoft.Json.JsonReader reader, System.Type objectType, Newtonsoft.Json.Serialization.JsonContract contract, Newtonsoft.Json.Serialization.JsonProperty member, Newtonsoft.Json.Serialization.JsonContainerContract containerContract, Newtonsoft.Json.Serialization.JsonProperty containerMember, System.Object existingValue) [0x00000] in <00000000000000000000000000000000>:0
at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateValueInternal (Newtonsoft.Json.JsonReader reader, System.Type objectType, Newtonsoft.Json.Serialization.JsonContract contract, Newtonsoft.Json.Serialization.JsonProperty member, Newtonsoft.Json.Serialization.JsonContainerContract containerContract, Newtonsoft.Json.Serialization.JsonProperty containerMember, System.Object existingValue) [0x00000] in <00000000000000000000000000000000>:0
at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.Deserialize (Newtonsoft.Json.JsonReader reader, System.Type objectType, System.Boolean checkAdditionalContent) [0x00000] in <00000000000000000000000000000000>:0
at Newtonsoft.Json.JsonSerializer.DeserializeInternal (Newtonsoft.Json.JsonReader reader, System.Type objectType) [0x00000] in <00000000000000000000000000000000>:0
at Newtonsoft.Json.JsonConvert.DeserializeObject (System.String value, System.Type type, Newtonsoft.Json.JsonSerializerSettings settings) [0x00000] in <00000000000000000000000000000000>:0
at Newtonsoft.Json.JsonConvert.DeserializeObject[T] (System.String value, Newtonsoft.Json.JsonSerializerSettings settings) [0x00000] in <00000000000000000000000000000000>:0
at Siccity.GLTFUtility.Importer.ImportGLTF (System.String filepath, Siccity.GLTFUtility.ImportSettings importSettings, Siccity.GLTFUtility.GLTFAnimation+ImportResult[]& animations) [0x00000] in <00000000000000000000000000000000>:0
at Siccity.GLTFUtility.Importer.LoadFromFile (System.String filepath, Siccity.GLTFUtility.Format format) [0x00000] in <00000000000000000000000000000000>:0
at Loader.Start () [0x00000] in <00000000000000000000000000000000>:0
Rethrow as JsonException: Error creating 'Siccity.GLTFUtility.Converters.TranslationConverter'.
at Newtonsoft.Json.Serialization.JsonTypeReflector+<>c__DisplayClass22_0.<GetCreator>b__0 (System.Object[] parameters) [0x00000] in <00000000000000000000000000000000>:0
at System.Func`2[T,TResult].Invoke (T arg) [0x00000] in <00000000000000000000000000000000>:0
at Newtonsoft.Json.Serialization.JsonTypeReflector.GetJsonConverter (System.Object attributeProvider) [0x00000] in <00000000000000000000000000000000>:0
at Newtonsoft.Json.Serialization.DefaultContractResolver.SetPropertySettingsFromAttributes (Newtonsoft.Json.Serialization.JsonProperty property, System.Object attributeProvider, System.String name, System.Type declaringType, Newtonsoft.Json.MemberSerialization memberSerialization, System.Boolean& allowNonPublicAccess) [0x00000] in <00000000000000000000000000000000>:0
at Newtonsoft.Json.Serialization.DefaultContractResolver.CreateProperty (System.Reflection.MemberInfo member, Newtonsoft.Json.MemberSerialization memberSerialization) [0x00000] in <00000000000000000000000000000000>:0
at Newtonsoft.Json.Serialization.DefaultContractResolver.CreateProperties (System.Type type, Newtonsoft.Json.MemberSerialization memberSerialization) [0x00000] in <00000000000000000000000000000000>:0
at Newtonsoft.Json.Serialization.DefaultContractResolver.CreateObjectContract (System.Type objectType) [0x00000] in <00000000000000000000000000000000>:0
at System.Func`2[T,TResult].Invoke (T arg) [0x00000] in <00000000000000000000000000000000>:0
at System.Collections.Concurrent.ConcurrentDictionary`2[TKey,TValue].GetOrAdd (TKey key, System.Func`2[T,TResult] valueFactory) [0x00000] in <00000000000000000000000000000000>:0
at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.PopulateList (System.Collections.IList list, Newtonsoft.Json.JsonReader reader, Newtonsoft.Json.Serialization.JsonArrayContract contract, Newtonsoft.Json.Serialization.JsonProperty containerProperty, System.String id) [0x00000] in <00000000000000000000000000000000>:0
at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateList (Newtonsoft.Json.JsonReader reader, System.Type objectType, Newtonsoft.Json.Serialization.JsonContract contract, Newtonsoft.Json.Serialization.JsonProperty member, System.Object existingValue, System.String id) [0x00000] in <00000000000000000000000000000000>:0
at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateValueInternal (Newtonsoft.Json.JsonReader reader, System.Type objectType, Newtonsoft.Json.Serialization.JsonContract contract, Newtonsoft.Json.Serialization.JsonProperty member, Newtonsoft.Json.Serialization.JsonContainerContract containerContract, Newtonsoft.Json.Serialization.JsonProperty containerMember, System.Object existingValue) [0x00000] in <00000000000000000000000000000000>:0
at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.SetPropertyValue (Newtonsoft.Json.Serialization.JsonProperty property, Newtonsoft.Json.JsonConverter propertyConverter, Newtonsoft.Json.Serialization.JsonContainerContract containerContract, Newtonsoft.Json.Serialization.JsonProperty containerProperty, Newtonsoft.Json.JsonReader reader, System.Object target) [0x00000] in <00000000000000000000000000000000>:0
at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.PopulateObject (System.Object newObject, Newtonsoft.Json.JsonReader reader, Newtonsoft.Json.Serialization.JsonObjectContract contract, Newtonsoft.Json.Serialization.JsonProperty member, System.String id) [0x00000] in <00000000000000000000000000000000>:0
at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateObject (Newtonsoft.Json.JsonReader reader, System.Type objectType, Newtonsoft.Json.Serialization.JsonContract contract, Newtonsoft.Json.Serialization.JsonProperty member, Newtonsoft.Json.Serialization.JsonContainerContract containerContract, Newtonsoft.Json.Serialization.JsonProperty containerMember, System.Object existingValue) [0x00000] in <00000000000000000000000000000000>:0
at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateValueInternal (Newtonsoft.Json.JsonReader reader, System.Type objectType, Newtonsoft.Json.Serialization.JsonContract contract, Newtonsoft.Json.Serialization.JsonProperty member, Newtonsoft.Json.Serialization.JsonContainerContract containerContract, Newtonsoft.Json.Serialization.JsonProperty containerMember, System.Object existingValue) [0x00000] in <00000000000000000000000000000000>:0
at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.Deserialize (Newtonsoft.Json.JsonReader reader, System.Type objectType, System.Boolean checkAdditionalContent) [0x00000] in <00000000000000000000000000000000>:0
at Newtonsoft.Json.JsonSerializer.DeserializeInternal (Newtonsoft.Json.JsonReader reader, System.Type objectType) [0x00000] in <00000000000000000000000000000000>:0
at Newtonsoft.Json.JsonConvert.DeserializeObject (System.String value, System.Type type, Newtonsoft.Json.JsonSerializerSettings settings) [0x00000] in <00000000000000000000000000000000>:0
at Newtonsoft.Json.JsonConvert.DeserializeObject[T] (System.String value, Newtonsoft.Json.JsonSerializerSettings settings) [0x00000] in <00000000000000000000000000000000>:0
at Siccity.GLTFUtility.Importer.ImportGLTF (System.String filepath, Siccity.GLTFUtility.ImportSettings importSettings, Siccity.GLTFUtility.GLTFAnimation+ImportResult[]& animations) [0x00000] in <00000000000000000000000000000000>:0
at Siccity.GLTFUtility.Importer.LoadFromFile (System.String filepath, Siccity.GLTFUtility.Format format) [0x00000] in <00000000000000000000000000000000>:0
at Loader.Start () [0x00000] in <00000000000000000000000000000000>:0
(Filename: currently not available on il2cpp Line: -1)
Let me know if I’m making too many issues- just figured it would be good to separate feature requests somewhat!
I’d love to see an option to choose between import/calculate for normals, as well as a “Generate lightmaps” feature similar to standard unity model import settings.
Message appears as a yellow warning in console on import of some models (example ReciprocatingSaw from https://github.com/KhronosGroup/glTF-Sample-Models) without any further information or stack trace
Identifier uniqueness violation: 'Material_22'. Scripted Importers do not guarantee that subsequent imports of this asset will properly re-link to these targets.
I noticed that on my import into a LWRP project (Unity 2019.2.3), the materials on the imported model were entirely magenta. The shaders GLTFUtility uses to generate materials do not support the custom render pipelines by default.
Rigs only work when exported in their resting pose.
Relevant script is GLTFSkin
I imported a colored glb model at runtime but the colors didn't display. I created the model online using Tinkercad. Imported it under the Lightweight Render Pipeline within Unity. The colors seem to work if I remove the Lightweight Render Pipeline script in the graphics settings. To replicate:
Model:
https://poly.google.com/view/eu-5IFEOh6C
Error:
Siccity.GLTFUtility.GLTFMaterial+ImportTask.OnMainThreadFinalize () (at Assets/GLTFUtility/Scripts/Spec/GLTFMaterial.cs:225)
Siccity.GLTFUtility.Importer+ImportTask`1[TReturn].RunSynchronously () (at Assets/GLTFUtility/Scripts/Importer.cs:96)
Siccity.GLTFUtility.Importer.LoadInternal (Siccity.GLTFUtility.GLTFObject gltfObject, System.String filepath, Siccity.GLTFUtility.ImportSettings importSettings, Siccity.GLTFUtility.GLTFAnimation+ImportResult[]& animations) (at Assets/GLTFUtility/Scripts/Importer.cs:138)
Siccity.GLTFUtility.Importer.ImportGLB (System.String filepath, Siccity.GLTFUtility.ImportSettings importSettings, Siccity.GLTFUtility.GLTFAnimation+ImportResult[]& animations) (at Assets/GLTFUtility/Scripts/Importer.cs:69)
Siccity.GLTFUtility.Importer.LoadFromFile (System.String filepath, Siccity.GLTFUtility.ImportSettings importSettings, Siccity.GLTFUtility.GLTFAnimation+ImportResult[]& animations, Siccity.GLTFUtility.Format format) (at Assets/GLTFUtility/Scripts/Importer.cs:26)
Siccity.GLTFUtility.GLBImporter.OnImportAsset (UnityEditor.Experimental.AssetImporters.AssetImportContext ctx) (at Assets/GLTFUtility/Scripts/Editor/GLBImporter.cs:11)
UnityEditor.Experimental.AssetImporters.ScriptedImporter.GenerateAssetData (UnityEditor.Experimental.AssetImporters.AssetImportContext ctx) (at C:/buildslave/unity/build/Modules/AssetPipelineEditor/Public/ScriptedImporter.cs:20)
Hi,
I made a model in Sketchup and exported it to gltf using the Khronos plugin. When I import the gltf in Unity, some faces are missing, while everything looks good in the Windows 3D viewer (and sketchup, obviously).
I'm not sure if I'm doing something wrong or if there is a bug in the importer.
Edit : seems there is something wrong with the Khronos gltf exporter itself : I opened the gltf directly in Unity without using your GLTFUtility, and I have the same issue. I also redesigned the missing face without success. Now I don't understand why it looks good in the windows 3d viewer...
Here is the gltf file :
house_2.zip
The missing face is the top floor upper face. It should look like this (screenshot from windows 3d viewer) :
But in unity, the top face is missing :
while the bottom face looks ok :
Error ocured when I tried import glb with animation
"Can't use AnimationClip::SetCurve at Runtime on non Legacy"
Suggested fix:
set new created animation type to legacy in GLTFAnimation.cs
result.clip.legacy = true;
Asset import failed, "Assets/box.gltf" > DirectoryNotFoundException: Could not find a part of the path "/Users/a.shchukin/projects/gltf/Assets/data:application/octet-stream;base64,AACAvwAAgD8AAIA/AACAPwAAgD8AAIC/AACAvwAAgD8AAIC/AACAPwAAgD8AAIA/AACAPwAAgD8AAIA/AACAvwAAgL8AAIA/AACAPwAAgL8AAIA/AACAvwAAgD8AAIA/AACAvwAAgD8AAIA/AACAvwAAgL8AAIC/AACAvwAAgL8AAIA/AACAvwAAgD8AAIC/AACAPwAAgL8AAIA/AACAvwAAgL8AAIC/AACAPwAAgL8AAIC/AACAvwAAgL8AAIA/AACAPwAAgD8AAIC/AACAPwAAgL8AAIA/AACAPwAAgL8AAIC/AACAPwAAgD8AAIA/AACAvwAAgD8AAIC/AACAPwAAgL8AAIC/AACAvwAAgL8AAIC/AACAPwAAgD8AAIC/AAAAAAAAgD8AAAAAAAAAAAAAgD8AAAAAAAAAAAAAgD8AAAAAAAAAAAAAgD8AAAAAAAAAAAAAAAAAAIA/AAAAAAAAAAAAAIA/AAAAAAAAAAAAAIA/AAAAAAAAAAAAAIA/AACAvwAAAAAAAAAAAACAvwAAAAAAAAAAAACAvwAAAAAAAAAAAACAvwAAAAAAAAAAAAAAAAAAgL8AAACAAAAAAAAAgL8AAACAAAAAAAAAgL8AAACAAAAAAAAAgL8AAACAAACAPwAAAAAAAAAAAACAPwAAAAAAAAAAAACAPwAAAAAAAAAAAACAPwAAAAAAAAAAAAAAAAAAAAAAAIC/AAAAAAAAAAAAAIC/AAAAAAAAAAAAAIC/AAAAAAAAAAAAAIC/AAAgPwAAQD8AAMA+AACAPwAAID8AAIA/AADAPgAAQD8AACA/AABAPwAAwD4AAAA/AADAPgAAQD8AACA/AAAAPwAAID8AAAA/AADAPgAAgD4AAMA+AAAAPwAAID8AAIA+AAAgPwAAAAAAAMA+AACAPgAAID8AAIA+AADAPgAAAAAAAMA+AAAAPwAAAD4AAIA+AAAAPgAAAD8AAMA+AACAPgAAYD8AAAA/AAAgPwAAgD4AACA/AAAAPwAAYD8AAIA+AAABAAIAAAADAAEABAAFAAYABAAHAAUACAAJAAoACAALAAkADAANAA4ADAAPAA0AEAARABIAEAATABEAFAAVABYAFAAXABUA".
System.IO.FileStream..ctor (System.String path, System.IO.FileMode mode, System.IO.FileAccess access, System.IO.FileShare share, System.Int32 bufferSize, System.Boolean anonymous, System.IO.FileOptions options) (at :0)
System.IO.FileStream..ctor (System.String path, System.IO.FileMode mode, System.IO.FileAccess access, System.IO.FileShare share) (at :0)
(wrapper remoting-invoke-with-check) System.IO.FileStream..ctor(string,System.IO.FileMode,System.IO.FileAccess,System.IO.FileShare)
System.IO.File.OpenRead (System.String path) (at :0)
System.IO.File.ReadAllBytes (System.String path) (at :0)
Siccity.GLTFUtility.GLTFBuffer.Read (System.String directoryRoot, System.String mainFile) (at Assets/GLTFUtility/Scripts/GLTFBuffer.cs:18)
Siccity.GLTFUtility.GLTFObject.Create (System.String directoryRoot, System.String mainFile) (at Assets/GLTFUtility/Scripts/GLTFObject.cs:29)
Siccity.GLTFUtility.GLTFImporter.OnImportAsset (UnityEditor.Experimental.AssetImporters.AssetImportContext ctx) (at Assets/GLTFUtility/Scripts/Editor/GLTFImporter.cs:18)
UnityEditor.Experimental.AssetImporters.ScriptedImporter.GenerateAssetData (UnityEditor.Experimental.AssetImporters.AssetImportContext ctx) (at /Users/builduser/buildslave/unity/build/Modules/AssetPipelineEditor/Public/ScriptedImporter.cs:20)
I am getting this error while importing a gltf file:
Asset import failed, "Assets/La Noscea/_0x29d90007.gltf" > NullReferenceException: Object reference not set to an instance of an object
Siccity.GLTFUtility.GLTFMaterial.TryGetTexture (Siccity.GLTFUtility.GLTFTexture+ImportResult[] textures, Siccity.GLTFUtility.GLTFMaterial+TextureInfo texture, UnityEngine.Texture2D& tex) (at Library/PackageCache/com.siccity.gltfutility@32b2b5281fff71808d1ea928c78f33ca67944ffa/Scripts/Spec/GLTFMaterial.cs:80)
Siccity.GLTFUtility.GLTFMaterial.CreateMaterial (Siccity.GLTFUtility.GLTFTexture+ImportResult[] textures, Siccity.GLTFUtility.ShaderSettings shaderSettings) (at Library/PackageCache/com.siccity.gltfutility@32b2b5281fff71808d1ea928c78f33ca67944ffa/Scripts/Spec/GLTFMaterial.cs:50)
Siccity.GLTFUtility.GLTFMaterial+ImportTask.OnMainThreadFinalize () (at Library/PackageCache/com.siccity.gltfutility@32b2b5281fff71808d1ea928c78f33ca67944ffa/Scripts/Spec/GLTFMaterial.cs:224)
Siccity.GLTFUtility.Importer+ImportTask`1[TReturn].RunSynchronously () (at Library/PackageCache/com.siccity.gltfutility@32b2b5281fff71808d1ea928c78f33ca67944ffa/Scripts/Importer.cs:96)
Siccity.GLTFUtility.Importer.LoadInternal (Siccity.GLTFUtility.GLTFObject gltfObject, System.String filepath, Siccity.GLTFUtility.ImportSettings importSettings, Siccity.GLTFUtility.GLTFAnimation+ImportResult[]& animations) (at Library/PackageCache/com.siccity.gltfutility@32b2b5281fff71808d1ea928c78f33ca67944ffa/Scripts/Importer.cs:138)
Siccity.GLTFUtility.Importer.ImportGLTF (System.String filepath, Siccity.GLTFUtility.ImportSettings importSettings, Siccity.GLTFUtility.GLTFAnimation+ImportResult[]& animations) (at Library/PackageCache/com.siccity.gltfutility@32b2b5281fff71808d1ea928c78f33ca67944ffa/Scripts/Importer.cs:77)
Siccity.GLTFUtility.Importer.LoadFromFile (System.String filepath, Siccity.GLTFUtility.ImportSettings importSettings, Siccity.GLTFUtility.GLTFAnimation+ImportResult[]& animations, Siccity.GLTFUtility.Format format) (at Library/PackageCache/com.siccity.gltfutility@32b2b5281fff71808d1ea928c78f33ca67944ffa/Scripts/Importer.cs:28)
Siccity.GLTFUtility.GLTFImporter.OnImportAsset (UnityEditor.Experimental.AssetImporters.AssetImportContext ctx) (at Library/PackageCache/com.siccity.gltfutility@32b2b5281fff71808d1ea928c78f33ca67944ffa/Scripts/Editor/GLTFImporter.cs:14)
UnityEditor.Experimental.AssetImporters.ScriptedImporter.GenerateAssetData (UnityEditor.Experimental.AssetImporters.AssetImportContext ctx) (at C:/buildslave/unity/build/Modules/AssetPipelineEditor/Public/ScriptedImporter.cs:20)
Notably, the release unitypackage works as expected. Hoping to get some of the features that have been added since however if possible.
The importer should be able to import materials with the LWRP/URP and HDRP shaders, depending on the project configuration.
Tried your demo project and while loading this glb https://unity-video.s3-ap-southeast-1.amazonaws.com/181C41E3-653C-4AD6-B76F-F4AE1553FFF3.glb its giving error saying
TestLoader: loading failed!
The Readme shows a nice example of animation in progress and the tool does process animations.
However, in the code the Animations are only returned to the importer and don't appear to "go anywhere"
Is there an example project or scene using the importer demonstrating animations?
Unity is z forward, glTF is -z forward. To counter this i got some code that flips the entire node tree on the z-axis as a final step in GLTFObject.cs. This isn't applied for animations though, so they look oddly 'inverted'
the gltf imports into blender (in blender the parts are transparent for some reason, but all the faces are there, maybe it's doing something to guess the faces?) but when i try and import it to unity i only get a few of the meshes, the gltf was exported from three.js by means of the GTLFExporter, and i will attach it here.
scene (8).zip
you can see the pegs import just fine, but the sides and the shelves are no where to be seen (one of the sides is mesh20, can tell by all the vertices)
thing is, i have no idea where the problem IS, is it the export or the import, i can say that blender is able to export and unity's 3d viewer can view it...so...i suspect it's with the import.
Lack of support causes crash when importing monster.glb, as explained here #35
LogError:
GLTFImage.cs ToTexture2D() ERROR: Cannot connect to destination host
My code:
string path = Application.streamingAssetsPath;
Importer.LoadFromFile(path + "/Lantern/glTF/Lantern.gltf");
My file:
Lantern.zip
Error code:
#if !UNITY_EDITOR && ( UNITY_ANDROID || UNITY_IOS )
path = "File://" + path;
#endif
// TODO: Support linear/sRGB textures
using(UnityWebRequest uwr = UnityWebRequestTexture.GetTexture(path, true))
{
UnityWebRequestAsyncOperation operation = uwr.SendWebRequest();
float progress = 0;
while (!operation.isDone)
{
if (progress != uwr.downloadProgress)
{
if (onProgress != null) onProgress(uwr.downloadProgress);
}
yield return null;
}
if (onProgress != null) onProgress(1f);
if (uwr.isNetworkError || uwr.isHttpError)
{
Debug.LogError("GLTFImage.cs ToTexture2D() ERROR: " + uwr.error);
}
else
{
Texture2D tex = DownloadHandlerTexture.GetContent(uwr);
tex.name = Path.GetFileNameWithoutExtension(path);
onFinish(tex);
}
uwr.Dispose();
}
Model:
https://github.com/KhronosGroup/glTF-Sample-Models/tree/master/2.0/Monster/glTF-Binary
Error:
Mesh 'monster': abnormal mesh bounds - most likely it has some invalid vertices (+/-inifinity or NANs) due to errors exporting.
Mesh bounds min=(-451080789585213150228586868600995840.00, -117474783433508707118662977875045515264.00, -inf), max=(201716128847098024439223546364158803968.00, 124780588502382453412050473577273622528.00, inf). Please make sure the mesh is exported without any errors.
Failed setting triangles. Some indices are referencing out of bounds vertices. IndexCount: 2652, VertexCount: 780
UnityEngine.Mesh:SetTriangles(Int32[], Int32)
Siccity.GLTFUtility.MeshData:ToMesh() (at Assets/GLTFUtility/Scripts/Spec/GLTFMesh.cs:123)
Siccity.GLTFUtility.ImportTask:OnMainThreadFinalize() (at Assets/GLTFUtility/Scripts/Spec/GLTFMesh.cs:205)
Siccity.GLTFUtility.ImportTask1:RunSynchronously() (at Assets/GLTFUtility/Scripts/Importer.cs:96) Siccity.GLTFUtility.Importer:LoadInternal(GLTFObject, String, ImportSettings, ImportResult[]&) (at Assets/GLTFUtility/Scripts/Importer.cs:140) Siccity.GLTFUtility.Importer:ImportGLB(String, ImportSettings, ImportResult[]&) (at Assets/GLTFUtility/Scripts/Importer.cs:69) Siccity.GLTFUtility.Importer:LoadFromFile(String, ImportSettings, ImportResult[]&, Format) (at Assets/GLTFUtility/Scripts/Importer.cs:31) Siccity.GLTFUtility.Importer:LoadFromFile(String, Format) (at Assets/GLTFUtility/Scripts/Importer.cs:16) Modules.Model.GltfModelLoader:LoadModel(String, Action
1) (at Assets/_Mondo/SubModules/Modules/Modules/Model/Scripts/GltfModelLoader.cs:17)
Modules.Model.ModelController:OnModelDownloaded(String) (at Assets/_Mondo/SubModules/Modules/Modules/Model/Scripts/ModelController.cs:80)
Modules.Model.<>c__DisplayClass5_0:b__0(String) (at Assets/_Mondo/SubModules/Modules/Modules/Model/Scripts/CachedModelDownloader.cs:89)
Modules.Model.d__8:MoveNext() (at Assets/_Mondo/SubModules/Modules/Modules/Model/Scripts/CachedModelDownloader.cs:175)
UnityEngine.SetupCoroutine:InvokeMoveNext(IEnumerator, IntPtr)
Code:
Importer.ImportGLTFAsync(path, new ImportSettings(),
model =>
{
onModelLoaded?.Invoke(model);
});
Model:
https://poly.google.com/view/eu-5IFEOh6C
Error:
JsonReaderException: Unexpected character encountered while parsing value: g. Path '', line 0, position 0.
Newtonsoft.Json.JsonTextReader.ParseValue () (at <97722d3abc9f4cf69f9e21e6770081b3>:0)
Newtonsoft.Json.JsonTextReader.Read () (at <97722d3abc9f4cf69f9e21e6770081b3>:0)
Newtonsoft.Json.JsonReader.ReadAndMoveToContent () (at <97722d3abc9f4cf69f9e21e6770081b3>:0)
Newtonsoft.Json.Serialization.JsonSerializerInternalReader.ReadForType (Newtonsoft.Json.JsonReader reader, Newtonsoft.Json.Serialization.JsonContract contract, System.Boolean hasConverter) (at <97722d3abc9f4cf69f9e21e6770081b3>:0)
Newtonsoft.Json.Serialization.JsonSerializerInternalReader.Deserialize (Newtonsoft.Json.JsonReader reader, System.Type objectType, System.Boolean checkAdditionalContent) (at <97722d3abc9f4cf69f9e21e6770081b3>:0)
Newtonsoft.Json.JsonSerializer.DeserializeInternal (Newtonsoft.Json.JsonReader reader, System.Type objectType) (at <97722d3abc9f4cf69f9e21e6770081b3>:0)
Newtonsoft.Json.JsonSerializer.Deserialize (Newtonsoft.Json.JsonReader reader, System.Type objectType) (at <97722d3abc9f4cf69f9e21e6770081b3>:0)
Newtonsoft.Json.JsonConvert.DeserializeObject (System.String value, System.Type type, Newtonsoft.Json.JsonSerializerSettings settings) (at <97722d3abc9f4cf69f9e21e6770081b3>:0)
Newtonsoft.Json.JsonConvert.DeserializeObject[T] (System.String value, Newtonsoft.Json.JsonSerializerSettings settings) (at <97722d3abc9f4cf69f9e21e6770081b3>:0)
Newtonsoft.Json.JsonConvert.DeserializeObject[T] (System.String value) (at <97722d3abc9f4cf69f9e21e6770081b3>:0)
Siccity.GLTFUtility.Importer+<>c__DisplayClass9_0.b__0 () (at Assets/GLTFUtility/Scripts/Importer.cs:154)
System.Threading.Tasks.Task1[TResult].InnerInvoke () (at <df7127ba07dc446d9f5831a0ec7b1d63>:0) System.Threading.Tasks.Task.Execute () (at <df7127ba07dc446d9f5831a0ec7b1d63>:0) Rethrow as AggregateException: One or more errors occurred. System.Threading.Tasks.Task.ThrowIfExceptional (System.Boolean includeTaskCanceledExceptions) (at <df7127ba07dc446d9f5831a0ec7b1d63>:0) System.Threading.Tasks.Task
1[TResult].GetResultCore (System.Boolean waitCompletionNotification) (at :0)
System.Threading.Tasks.Task`1[TResult].get_Result () (at :0)
Siccity.GLTFUtility.Importer+d__9.MoveNext () (at Assets/GLTFUtility/Scripts/Importer.cs:157)
UnityEngine.SetupCoroutine.InvokeMoveNext (System.Collections.IEnumerator enumerator, System.IntPtr returnValueAddress) (at C:/buildslave/unity/build/Runtime/Export/Coroutines.cs:17)
Stuff like draco mesh compression, specular materials, and texture transforms, are all optional and not part of the spec. Therefore, these should be moved to separate projects managed independently of GLTFUtility. The API should be open for allowing more plugins to seamlessly integrate with the core.
Message appears as a red error in console on import of some models (example Triangle from https://github.com/KhronosGroup/glTF-Sample-Models) without any further information or stack trace.
JSONUtility is fine for a lot of things, but it has proven inadequate for GLTFUtility.
The GLTF format can store a lot of optional parameters, parameters that you cannot exclude from serializing with JSONUtility.
So in the future, the plan is to require NewtonsoftJSON be installed on the users machine.
Simplejson is faster and requires less class generation why it is not used in the GLTF utility? I need to get the best performance for the mobile I wonder if newton json has some essential features simple json does not.
Unity supports 4 bones per vertex. That amounts to WEIGHTS_0 (4 float values) and JOINTS_0 (4 int values) in the gltf file. However, when an exported file also contains WEIGHTS_1 (4 more floats) and JOINTS_1 (4 more ints), or possibly more, we need to downscale this to only use 4 values at max.
I tried taking the 4 'heaviest' weight/joint pairs (in the skinning branch) and discarding the rest, but the result is a little off from the desired result produced by other importers.
Here's the test model in fbx and gltf format
character.zip
I liked the way you are organizing this project, it's much better than UnityGLTF from Khronos Group. But the only reason I'm not switching to your project now is that your product seems to be better used in the editor, not runtime, since you don't support async importing yet
I´ve posted this in the Unityforums. But since both are related, i´m posting it also here.
Link to the original post: https://forum.unity.com/threads/gltf-unity-bug-missing-feature-wrong-behaviour.731120/
The user run the application. A File Opener dialog is open, in which the user selects the GLTF File to be loaded. The File is loaded and is shown in screen.
The problem:
Everything works perfect in Editor. In Build nothing seems to work.
This occurs NOT ONLY with the "UniGLTF" from @Siccity but also the UnityGLTF from @Khronos
Link to the project: https://drive.google.com/open?id=1ThMY27BhH9Uxqg3kSUWMcKjHBZib5YDX
Hi there,
when exporting materials from blender, there are texture information about scale and offset which are not yet applied on unity import.
See example here:
"materials" : [
{
"doubleSided" : true,
"name" : "someMaterial",
"normalTexture" : {
"extensions" : {
"KHR_texture_transform" : {
"offset" : [
0,
-3
],
"scale" : [
4,
4
]
}
},
"index" : 0,
"texCoord" : 0
},
}
]
After adding the required entries into the package manifest.json, I am receiving multiple entries of the error:
error CS0246: The type or namespace name 'Newtonsoft' could not be found (are you missing a using directive or an assembly reference?)
My manifest:
...
"com.unity.multiplayer-hlapi": "1.0.4",
"com.unity.nuget.newtonsoft-json": "1.1.2",
"com.siccity.gltfutility": "https://github.com/siccity/gltfutility.git",
"com.unity.test-framework": "1.1.9",
"com.unity.textmeshpro": "2.0.1",
"com.unity.timeline": "1.2.10",
"com.unity.ugui": "1.0.0",
...
Should there be an entry in the GLTFUtility.asmdef and if so, what should it me?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.