Skip to content

Commit

Permalink
Fix an issue with wire route callbacks being cleared on reload
Browse files Browse the repository at this point in the history
  • Loading branch information
FilipAlg committed Jan 21, 2025
1 parent 76b86c0 commit b4fd0f4
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion AGXUnity/WireRoute.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ namespace AGXUnity
/// Wire.RouteNode myNode = route.FirstOrDefault( node => node.Frame == thisFrame );
/// </example>
[Serializable]
public class WireRoute : Route<WireRouteNode>
public class WireRoute : Route<WireRouteNode>, ISerializationCallbackReceiver
{
/// <summary>
/// Checks validity of current route.
Expand Down Expand Up @@ -177,5 +177,16 @@ private void OnRemovedFromList( WireRouteNode node, int index )
{
node.Wire = null;
}

public void OnBeforeSerialize() { }

public void OnAfterDeserialize()
{
// Remove callback if it exists to avoid any possible duplicates
OnNodeAdded -= this.OnAddedToList;
OnNodeRemoved -= this.OnRemovedFromList;
OnNodeAdded += this.OnAddedToList;
OnNodeRemoved += this.OnRemovedFromList;
}
}
}

0 comments on commit b4fd0f4

Please sign in to comment.