Skip to content

Commit

Permalink
add: setting to determine if vertex colors are exported
Browse files Browse the repository at this point in the history
  • Loading branch information
hybridherbst committed Jun 14, 2021
1 parent 52946fb commit fff9378
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -1146,7 +1146,7 @@ private MeshPrimitive[] ExportPrimitive(GameObject gameObject, GLTFMesh mesh)
if (meshObj.uv2.Length != 0)
aTexcoord1 = ExportAccessor(SchemaExtensions.FlipTexCoordArrayVAndCopy(meshObj.uv2));

if (meshObj.colors.Length != 0)
if (settings.ExportVertexColors && meshObj.colors.Length != 0)
aColor0 = ExportAccessor(QualitySettings.activeColorSpace == ColorSpace.Linear ? meshObj.colors : meshObj.colors.ToLinear());

_meshToPrims.Add(meshObj, new MeshAccessors()
Expand Down
14 changes: 14 additions & 0 deletions UnityGLTF/Assets/UnityGLTF/Runtime/Scripts/GLTFSettings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,9 @@ public enum BlendShapeExportPropertyFlags
private BlendShapeExportPropertyFlags blendShapeExportProperties = BlendShapeExportPropertyFlags.All;
[SerializeField]
private bool bakeSkinnedMeshes = false;
[SerializeField]
[Tooltip("Vertex Colors aren't supported in some viewers (e.g. Google's SceneViewer).")]
private bool exportVertexColors = true;

public bool ExportNames { get => exportNames;
set {
Expand Down Expand Up @@ -147,6 +150,17 @@ public bool TryExportTexturesFromDisk
}
}

public bool ExportVertexColors
{ get => exportVertexColors;
set {
if(exportVertexColors != value) {
exportVertexColors = value;
#if UNITY_EDITOR
EditorUtility.SetDirty(this);
#endif
}
}
}
public bool ExportDisabledGameObjects
{ get => exportDisabledGameObjects;
set {
Expand Down

0 comments on commit fff9378

Please sign in to comment.