1
0
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:
Simon Rodriguez 2022-11-27 15:07:37 +01:00 committed by GitHub
parent 445af6e703
commit c7debc2346
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 4 additions and 0 deletions

View File

@ -406,7 +406,9 @@ namespace XNode {
public void OnAfterDeserialize() {
this.Clear();
#if UNITY_2021_3_OR_NEWER
this.EnsureCapacity(keys.Count);
#endif
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.");

View File

@ -37,7 +37,9 @@ namespace XNode {
List<NodePort> typePortCache;
if (portDataCache.TryGetValue(nodeType, out typePortCache)) {
#if UNITY_2021_3_OR_NEWER
staticPorts.EnsureCapacity(typePortCache.Count);
#endif
for (int i = 0; i < typePortCache.Count; i++) {
staticPorts.Add(typePortCache[i].fieldName, typePortCache[i]);
}