diff --git a/Editor/ABI/TypeCreatorBase.cs b/Editor/ABI/TypeCreatorBase.cs index 54b3ffd..9c98490 100644 --- a/Editor/ABI/TypeCreatorBase.cs +++ b/Editor/ABI/TypeCreatorBase.cs @@ -5,6 +5,7 @@ using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; +using UnityEngine; namespace HybridCLR.Editor.ABI { @@ -74,6 +75,10 @@ namespace HybridCLR.Editor.ABI case ElementType.ValueType: { TypeDef typeDef = type.ToTypeDefOrRef().ResolveTypeDef(); + if (typeDef == null) + { + throw new Exception($"type:{type} 未能找到定义。请尝试 `HybridCLR/Genergate/LinkXml`,然后Build一次生成AOT dll,再重新生成桥接函数"); + } if (typeDef.IsEnum) { return CreateTypeInfo(typeDef.GetEnumUnderlyingType()); diff --git a/Editor/ABI/ValueTypeSizeAligmentCalculator.cs b/Editor/ABI/ValueTypeSizeAligmentCalculator.cs index 5162271..a97dd02 100644 --- a/Editor/ABI/ValueTypeSizeAligmentCalculator.cs +++ b/Editor/ABI/ValueTypeSizeAligmentCalculator.cs @@ -74,11 +74,11 @@ namespace HybridCLR.Editor.ABI { continue; } - if (sa != null && typeDef.Layout.HasFlag(dnlib.DotNet.TypeAttributes.ExplicitLayout)) + if (typeDef.Layout.HasFlag(dnlib.DotNet.TypeAttributes.ExplicitLayout)) { int offset = (int)field.FieldOffset.Value; totalSize = Math.Max(totalSize, offset + fs); - if (offset > sa.ClassSize) + if (sa != null && offset > sa.ClassSize) { useSLSize = false; } @@ -90,7 +90,7 @@ namespace HybridCLR.Editor.ABI totalSize = (totalSize + fa - 1) / fa * fa; } totalSize += fs; - if (sa != null && typeDef.Layout.HasFlag(dnlib.DotNet.TypeAttributes.SequentialLayout) && totalSize > sa.ClassSize) + if (sa != null && totalSize > sa.ClassSize) { useSLSize = false; } diff --git a/package.json b/package.json index 029349b..2ad77f6 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "com.focus-creative-games.hybridclr_unity", - "version": "1.1.12", + "version": "1.1.13", "displayName": "HybridCLR", "description": "Unity package for HybridCLR. It includes editor and runtime scripts and assets for HybridCLR", "category": "Runtime",