Browse Source

Fixed saving extras when empty

Vicente Penades 6 years ago
parent
commit
e01c5827bb

+ 8 - 2
src/SharpGLTF.Core/Schema2/gltf.ExtraProperties.cs

@@ -143,10 +143,16 @@ namespace SharpGLTF.Schema2
                 SerializeProperty(writer, "extensions", dict);
             }
 
-            if (_extras != null)
+            if (_extras == null) return;
+
+            // todo, only write _extras if it's a known serializable type.
+
+            if (!(_extras is String) && _extras is System.Collections.IEnumerable collection)
             {
-                SerializeProperty(writer, "extras", _extras);
+                if (!collection.Cast<Object>().Any()) return;
             }
+
+            SerializeProperty(writer, "extras", _extras);
         }
 
         private static IReadOnlyDictionary<string, JsonSerializable> _ToDictionary(JsonSerializable context, IEnumerable<JsonSerializable> serializables)

+ 3 - 3
src/SharpGLTF.Core/Schema2/gltf.TextureInfo.cs

@@ -3,7 +3,7 @@ using System.Numerics;
 
 namespace SharpGLTF.Schema2
 {
-    [System.Diagnostics.DebuggerDisplay("Texture[{LogicalIndex}] {Name}")]
+    [System.Diagnostics.DebuggerDisplay("LogicalTexture[{_LogicalTextureIndex}]")]
     internal partial class TextureInfo
     {
         #region properties
@@ -102,7 +102,7 @@ namespace SharpGLTF.Schema2
         #endregion
     }
 
-    [System.Diagnostics.DebuggerDisplay("Normal Texture[{LogicalIndex}] {Name}")]
+    [System.Diagnostics.DebuggerDisplay("Normal LogicalTexture[{_LogicalTextureIndex}] x {Scale}")]
     internal sealed partial class MaterialNormalTextureInfo
     {
         #region properties
@@ -116,7 +116,7 @@ namespace SharpGLTF.Schema2
         #endregion
     }
 
-    [System.Diagnostics.DebuggerDisplay("Occlusion Texture[{LogicalIndex}] {Name}")]
+    [System.Diagnostics.DebuggerDisplay("Occlusion LogicalTexture[{_LogicalTextureIndex}] x {Strength}")]
     internal sealed partial class MaterialOcclusionTextureInfo
     {
         #region properties