diff --git a/Runtime/ClassicalUsages/ServiceContainer.cs b/Runtime/ClassicalUsages/ServiceContainer.cs index 1d02799..462aa69 100644 --- a/Runtime/ClassicalUsages/ServiceContainer.cs +++ b/Runtime/ClassicalUsages/ServiceContainer.cs @@ -90,13 +90,16 @@ static Info GetInfoWithCache(Type desiredType, Type declaringType) Info info; if (lutInfos.TryGetValue((desiredType, declaringType), out info)) return info; // first in order - foreach (var interfType in declaringType.GetInterfaces()) + if (declaringType != null) { - if (lutInfos.TryGetValue((desiredType, interfType), out info)) return info; - } - for (var curType = declaringType.BaseType; curType != null; curType = curType.BaseType) - { - if (lutInfos.TryGetValue((desiredType, curType), out info)) return info; + foreach (var interfType in declaringType.GetInterfaces()) + { + if (lutInfos.TryGetValue((desiredType, interfType), out info)) return info; + } + for (var curType = declaringType.BaseType; curType != null; curType = curType.BaseType) + { + if (lutInfos.TryGetValue((desiredType, curType), out info)) return info; + } } if (lutInfos.TryGetValue((desiredType, null), out info)) return info; // default cache diff --git a/package.json b/package.json index c64067a..aa79b53 100644 --- a/package.json +++ b/package.json @@ -2,7 +2,7 @@ "name": "com.bbbirder.injection", "displayName": "Unity Injection", "description": "Unity注入模块,可以运行时改变被注入函数实现。", - "version": "1.3.17", + "version": "1.3.18", "hideInEditor": false, "author": "bbbirder <502100554@qq.com>", "dependencies": {