1
0
mirror of https://github.com/Siccity/xNode.git synced 2025-12-20 09:16:01 +08:00

Removed GetHashCode override.

This should improve performance, but has previously caused a slew of bugs.
Bugtest thoroughly before merging
This commit is contained in:
Thor Brigsted 2019-02-16 12:21:21 +01:00
parent 3a8ae366f2
commit 57d3a03a91
2 changed files with 3 additions and 11 deletions

View File

@ -241,12 +241,10 @@ namespace XNodeEditor {
selectionCache = new List<UnityEngine.Object>(Selection.objects);
}
//Active node is hashed before and after node GUI to detect changes
int nodeHash = 0;
System.Reflection.MethodInfo onValidate = null;
if (Selection.activeObject != null && Selection.activeObject is XNode.Node) {
onValidate = Selection.activeObject.GetType().GetMethod("OnValidate");
if (onValidate != null) nodeHash = Selection.activeObject.GetHashCode();
if (onValidate != null) EditorGUI.BeginChangeCheck();
}
BeginZoomed(position, zoom, topPadding);
@ -383,12 +381,10 @@ namespace XNodeEditor {
if (e.type != EventType.Layout && currentActivity == NodeActivity.DragGrid) Selection.objects = preSelection.ToArray();
EndZoomed(position, zoom, topPadding);
//If a change in hash is detected in the selected node, call OnValidate method.
//If a change in is detected in the selected node, call OnValidate method.
//This is done through reflection because OnValidate is only relevant in editor,
//and thus, the code should not be included in build.
if (nodeHash != 0) {
if (onValidate != null && nodeHash != Selection.activeObject.GetHashCode()) onValidate.Invoke(Selection.activeObject, null);
}
if (onValidate != null && EditorGUI.EndChangeCheck()) onValidate.Invoke(Selection.activeObject, null);
}
private bool ShouldBeCulled(XNode.Node node) {

View File

@ -205,10 +205,6 @@ namespace XNode {
foreach (NodePort port in Ports) port.ClearConnections();
}
public override int GetHashCode() {
return JsonUtility.ToJson(this).GetHashCode();
}
#region Attributes
/// <summary> Mark a serializable field as an input port. You can access this through <see cref="GetInputPort(string)"/> </summary>
[AttributeUsage(AttributeTargets.Field, AllowMultiple = true)]