Skip to content

Commit

Permalink
Fixed Bug at Saving shared colors of overlaydata.
Browse files Browse the repository at this point in the history
  • Loading branch information
buronix committed Feb 17, 2016
1 parent dfad553 commit 64e6c38
Showing 1 changed file with 16 additions and 14 deletions.
30 changes: 16 additions & 14 deletions UMAProject/Assets/UMA/Example/Scripts/UMAPackedRecipeBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -384,7 +384,7 @@ public static UMAPackRecipe PackRecipeV2(UMA.UMAData.UMARecipe umaRecipe)
for (int i = 0; i < umaPackRecipe.sharedColorCount; i++)
{
colorEntries.Add(umaRecipe.sharedColors[i]);
packedColorEntries.Add(new PackedOverlayColorDataV3(umaRecipe.sharedColors[i]));
packedColorEntries.Add(new PackedOverlayColorDataV3(umaRecipe.sharedColors[i]));
}

for (int i = 0; i < slotCount; i++)
Expand Down Expand Up @@ -427,25 +427,27 @@ public static UMAPackRecipe PackRecipeV2(UMA.UMAData.UMARecipe umaRecipe)
tempPackedOverlay.rect[3] = Mathf.FloorToInt(overlayData.rect.height);

OverlayColorData colorData = overlayData.colorData;
// Could not use IndexOf to find color, since operator == overriden in OverlayColorData
int colorIndex = -1;
for (int col=0;col<colorEntries.Count;col++)
{
if (colorEntries[col].GetHashCode() == colorData.GetHashCode())
{
colorIndex = col;
}
}


int colorIndex = -1;
int cIndex = 0;
foreach(OverlayColorData cData in colorEntries)
{
if (cData.name.Equals(colorData.name))
{
colorIndex = cIndex;
break;
}
cIndex++;
}
if (colorIndex < 0)
{
PackedOverlayColorDataV3 newColorEntry = new PackedOverlayColorDataV3(colorData);
packedColorEntries.Add(newColorEntry);
colorIndex = colorEntries.Count;
colorEntries.Add(colorData);
}
tempPackedOverlay.colorIdx = colorIndex;

}

tempPackedOverlay.colorIdx = colorIndex;

tempPackedSlotData.overlays[overlayIdx] = tempPackedOverlay;
}
Expand Down

0 comments on commit 64e6c38

Please sign in to comment.