Skip to content

Commit

Permalink
Fix incorrect number of mesh colors extracted before 2018
Browse files Browse the repository at this point in the history
* This affected GLB export and Static Mesh Separation
  • Loading branch information
ds5678 committed Feb 20, 2024
1 parent f52342b commit 669a55d
Showing 1 changed file with 6 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -124,17 +124,19 @@ public static ChannelInfo GetChannel(this IVertexData instance, UnityVersion ver
for (int chn = 0; chn < channels.Count; chn++)
{
ChannelInfo m_Channel = channels[chn];

if (version.LessThan(2018) && chn == 2 && m_Channel.Format == 2) //kShaderChannelColor && kChannelFormatColor
{
m_Channel.SetDataDimension(4);
}

byte dimension = m_Channel.GetDataDimension();
if (dimension > 0)
{
IStreamInfo m_Stream = streams[m_Channel.Stream];
BitArray channelMask = new BitArray(BitConverter.GetBytes(m_Stream.ChannelMask));
if (channelMask.Get(chn))
{
if (version.LessThan(2018) && chn == 2 && m_Channel.Format == 2) //kShaderChannelColor && kChannelFormatColor
{
m_Channel.SetDataDimension(4);
}

MeshHelper.VertexFormat vertexFormat = MeshHelper.ToVertexFormat(m_Channel.Format, version);
int componentByteSize = MeshHelper.GetFormatSize(vertexFormat);
Expand Down

0 comments on commit 669a55d

Please sign in to comment.