From 71cf78a4877e7816cee03ee1c7eb502cf09a9f75 Mon Sep 17 00:00:00 2001 From: Jaimi Date: Tue, 5 Jan 2016 17:37:49 -0600 Subject: [PATCH] Issue where additive colors were being cleared in EnsureChannels Also did not process through copies if count was >= channel count. --- .../UMA/Core/Scripts/OverlayColorData.cs | 43 +++++++++++-------- 1 file changed, 24 insertions(+), 19 deletions(-) diff --git a/UMAProject/Assets/Standard Assets/UMA/Core/Scripts/OverlayColorData.cs b/UMAProject/Assets/Standard Assets/UMA/Core/Scripts/OverlayColorData.cs index e68e78a8..8a3c1cfe 100644 --- a/UMAProject/Assets/Standard Assets/UMA/Core/Scripts/OverlayColorData.cs +++ b/UMAProject/Assets/Standard Assets/UMA/Core/Scripts/OverlayColorData.cs @@ -170,31 +170,36 @@ public void EnsureChannels(int channels) { if (channelMask == null) { - channelMask = new Color[channels]; - channelAdditiveMask = new Color[channels]; + channelMask = new Color[channels]; + channelAdditiveMask = new Color[channels]; for (int i = 0; i < channels; i++) { - channelMask[i] = Color.white; - channelAdditiveMask[i] = new Color(0, 0, 0, 0); + channelMask[i] = Color.white; + channelAdditiveMask[i] = new Color(0, 0, 0, 0); } } else { - if( channelMask.Length > channels ) return; - - var oldLenth = channelMask.Length; - var newMask = new Color[channels]; - var newAdditive = new Color[channels]; - channelAdditiveMask = new Color[channels]; - System.Array.Copy(channelMask, newMask, oldLenth); - System.Array.Copy(channelAdditiveMask, newAdditive, oldLenth); - for (int i = oldLenth; i < channels; i++) - { - newMask[i] = Color.white; - newAdditive[i] = new Color(0, 0, 0, 0); - } - channelMask = newMask; - channelAdditiveMask = newAdditive; + if (channelMask.Length < channels) + { + var newMask = new Color[channels]; + System.Array.Copy(channelMask, newMask, channelMask.Length); + for (int i = channelMask.Length; i < channels; i++) + { + newMask[i] = Color.white; + } + channelMask = newMask; + } + if (channelAdditiveMask.Length < channels) + { + var newAdditiveMask = new Color[channels]; + System.Array.Copy(channelAdditiveMask, newAdditiveMask, channelAdditiveMask.Length); + for (int i = channelAdditiveMask.Length; i < channels; i++) + { + newAdditiveMask[i] = new Color(0,0,0,0); + } + channelAdditiveMask = newAdditiveMask; + } } }