Skip to content

Commit

Permalink
Fixed bug with saving shared colors during recipe packing
Browse files Browse the repository at this point in the history
the PackedRecipe save was using IndexOf to find the shared color, and
this returns invalid results since the OverlayColorData has overridden
the == operator to compare colors. This change solves the problem of
needing your shared colors to have different default values before it
would save them correctly.
  • Loading branch information
Jaimi committed Dec 29, 2015
1 parent 0093963 commit 1fdadf1
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -437,6 +437,23 @@ public bool OnGUI(ref bool _dnaDirty, ref bool _textureDirty, ref bool _meshDirt
_meshDirty |= true;
}

GUILayout.BeginHorizontal();
if (GUILayout.Button("Collapse All"))
{
foreach(SlotEditor se in _slotEditors)
{
se.FoldOut = false;
}
}
if (GUILayout.Button("Expand All"))
{
foreach(SlotEditor se in _slotEditors)
{
se.FoldOut = true;
}
}
GUILayout.EndHorizontal();

for (int i = 0; i < _slotEditors.Count; i++)
{
var editor = _slotEditors[i];
Expand Down Expand Up @@ -471,13 +488,19 @@ public class SlotEditor
{
private readonly UMAData.UMARecipe _recipe;
private readonly SlotData _slotData;
private readonly List<OverlayData> _overlayData = new List<OverlayData>();
private readonly List<OverlayEditor> _overlayEditors = new List<OverlayEditor>();
private readonly string _name;
private readonly List<OverlayData> _overlayData = new List<OverlayData>();
private readonly List<OverlayEditor> _overlayEditors = new List<OverlayEditor>();
private readonly string _name;

public bool Delete { get; private set; }
public bool Delete { get; private set; }

private bool _foldout = true;
public bool FoldOut
{
get { return _foldout; }
set {_foldout = value; }
}

private bool _foldout = true;
public bool sharedOverlays = false;
public int idx;

Expand Down
12 changes: 11 additions & 1 deletion UMAProject/Assets/UMA/Example/Scripts/UMAPackedRecipeBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -427,7 +427,17 @@ public static UMAPackRecipe PackRecipeV2(UMA.UMAData.UMARecipe umaRecipe)
tempPackedOverlay.rect[3] = Mathf.FloorToInt(overlayData.rect.height);

OverlayColorData colorData = overlayData.colorData;
int colorIndex = colorEntries.IndexOf(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;
}
}


if (colorIndex < 0)
{
PackedOverlayColorDataV3 newColorEntry = new PackedOverlayColorDataV3(colorData);
Expand Down

0 comments on commit 1fdadf1

Please sign in to comment.