mirror of
https://github.com/Siccity/xNode.git
synced 2025-12-20 01:06:01 +08:00
Merge pull request #365 from TriceHelix/master
Fix NullReferenceException
This commit is contained in:
commit
d6effd70f5
@ -1,4 +1,4 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using UnityEditor;
|
using UnityEditor;
|
||||||
@ -12,8 +12,8 @@ namespace XNodeEditor {
|
|||||||
/// <summary> Contains GUI methods </summary>
|
/// <summary> Contains GUI methods </summary>
|
||||||
public partial class NodeEditorWindow {
|
public partial class NodeEditorWindow {
|
||||||
public NodeGraphEditor graphEditor;
|
public NodeGraphEditor graphEditor;
|
||||||
private List<UnityEngine.Object> selectionCache;
|
private readonly HashSet<UnityEngine.Object> selectionCache = new();
|
||||||
private List<XNode.Node> culledNodes;
|
private readonly HashSet<XNode.Node> culledNodes = new();
|
||||||
/// <summary> 19 if docked, 22 if not </summary>
|
/// <summary> 19 if docked, 22 if not </summary>
|
||||||
private int topPadding { get { return isDocked() ? 19 : 22; } }
|
private int topPadding { get { return isDocked() ? 19 : 22; } }
|
||||||
/// <summary> Executed after all other window GUI. Useful if Zoom is ruining your day. Automatically resets after being run.</summary>
|
/// <summary> Executed after all other window GUI. Useful if Zoom is ruining your day. Automatically resets after being run.</summary>
|
||||||
@ -399,8 +399,13 @@ namespace XNodeEditor {
|
|||||||
|
|
||||||
private void DrawNodes() {
|
private void DrawNodes() {
|
||||||
Event e = Event.current;
|
Event e = Event.current;
|
||||||
|
|
||||||
if (e.type == EventType.Layout) {
|
if (e.type == EventType.Layout) {
|
||||||
selectionCache = new List<UnityEngine.Object>(Selection.objects);
|
selectionCache.Clear();
|
||||||
|
var objs = Selection.objects;
|
||||||
|
selectionCache.EnsureCapacity(objs.Length);
|
||||||
|
foreach (var obj in objs)
|
||||||
|
selectionCache.Add(obj);
|
||||||
}
|
}
|
||||||
|
|
||||||
System.Reflection.MethodInfo onValidate = null;
|
System.Reflection.MethodInfo onValidate = null;
|
||||||
@ -432,7 +437,7 @@ namespace XNodeEditor {
|
|||||||
|
|
||||||
List<XNode.NodePort> removeEntries = new List<XNode.NodePort>();
|
List<XNode.NodePort> removeEntries = new List<XNode.NodePort>();
|
||||||
|
|
||||||
if (e.type == EventType.Layout) culledNodes = new List<XNode.Node>();
|
if (e.type == EventType.Layout) culledNodes.Clear();
|
||||||
for (int n = 0; n < graph.nodes.Count; n++) {
|
for (int n = 0; n < graph.nodes.Count; n++) {
|
||||||
// Skip null nodes. The user could be in the process of renaming scripts, so removing them at this point is not advisable.
|
// Skip null nodes. The user could be in the process of renaming scripts, so removing them at this point is not advisable.
|
||||||
if (graph.nodes[n] == null) continue;
|
if (graph.nodes[n] == null) continue;
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user