mirror of
https://github.com/Siccity/xNode.git
synced 2025-12-20 01:06:01 +08:00
Added ifdef 2021_3_or_newer where Unity upgraded to net standard 2.1 where Dictionary.EnsureCapacity is added.
This commit is contained in:
parent
445af6e703
commit
c7debc2346
@ -406,7 +406,9 @@ namespace XNode {
|
|||||||
|
|
||||||
public void OnAfterDeserialize() {
|
public void OnAfterDeserialize() {
|
||||||
this.Clear();
|
this.Clear();
|
||||||
|
#if UNITY_2021_3_OR_NEWER
|
||||||
this.EnsureCapacity(keys.Count);
|
this.EnsureCapacity(keys.Count);
|
||||||
|
#endif
|
||||||
|
|
||||||
if (keys.Count != values.Count)
|
if (keys.Count != values.Count)
|
||||||
throw new System.Exception("there are " + keys.Count + " keys and " + values.Count + " values after deserialization. Make sure that both key and value types are serializable.");
|
throw new System.Exception("there are " + keys.Count + " keys and " + values.Count + " values after deserialization. Make sure that both key and value types are serializable.");
|
||||||
|
|||||||
@ -37,7 +37,9 @@ namespace XNode {
|
|||||||
|
|
||||||
List<NodePort> typePortCache;
|
List<NodePort> typePortCache;
|
||||||
if (portDataCache.TryGetValue(nodeType, out typePortCache)) {
|
if (portDataCache.TryGetValue(nodeType, out typePortCache)) {
|
||||||
|
#if UNITY_2021_3_OR_NEWER
|
||||||
staticPorts.EnsureCapacity(typePortCache.Count);
|
staticPorts.EnsureCapacity(typePortCache.Count);
|
||||||
|
#endif
|
||||||
for (int i = 0; i < typePortCache.Count; i++) {
|
for (int i = 0; i < typePortCache.Count; i++) {
|
||||||
staticPorts.Add(typePortCache[i].fieldName, typePortCache[i]);
|
staticPorts.Add(typePortCache[i].fieldName, typePortCache[i]);
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user