Fix error when opening Anim Graph with node name not existing in skeleton anymore

Fixes #176
This commit is contained in:
Wojtek Figat
2021-01-28 21:59:30 +01:00
parent 50f6a01f83
commit beecbffdc3

View File

@@ -32,8 +32,8 @@ namespace FlaxEditor.Surface.Elements
}
set
{
if (!string.IsNullOrEmpty(value))
SelectedIndex = _nodeNameToIndex[value];
if (!string.IsNullOrEmpty(value) && _nodeNameToIndex.TryGetValue(value, out var index))
SelectedIndex = index;
else
SelectedIndex = -1;
}
@@ -60,8 +60,8 @@ namespace FlaxEditor.Surface.Elements
{
_selectedIndices.Clear();
var selectedNode = (string)ParentNode.Values[Archetype.ValueIndex];
if (!string.IsNullOrEmpty(selectedNode))
_selectedIndices.Add(_nodeNameToIndex[selectedNode]);
if (!string.IsNullOrEmpty(selectedNode) && _nodeNameToIndex.TryGetValue(selectedNode, out var index))
_selectedIndices.Add(index);
OnSelectedIndexChanged();
}