FileNotFoundException: Could not load file or assembly 'UnityEngine.ClusterInputModule' or one of its dependencies. The system cannot find the file specified.
System.AppDomain.Load (System.Reflection.AssemblyName assemblyRef, System.Security.Policy.Evidence assemblySecurity) (at /Users/builduser/buildslave/mono/build/mcs/class/corlib/System/AppDomain.cs:692)
(wrapper remoting-invoke-with-check) System.AppDomain:Load (System.Reflection.AssemblyName,System.Security.Policy.Evidence)
System.AppDomain.Load (System.Reflection.AssemblyName assemblyRef) (at /Users/builduser/buildslave/mono/build/mcs/class/corlib/System/AppDomain.cs:657)
(wrapper remoting-invoke-with-check) System.AppDomain:Load (System.Reflection.AssemblyName)
System.Reflection.Assembly.Load (System.Reflection.AssemblyName assemblyRef) (at /Users/builduser/buildslave/mono/build/mcs/class/corlib/System.Reflection/Assembly.cs:589)
AssemblyLister.Lister.DeepWalkReferences (System.Reflection.Assembly assembly, System.Collections.Generic.HashSet1 seen)
AssemblyLister.Lister.DeepWalkReferences (System.Reflection.Assembly assembly, System.Collections.Generic.HashSet
1 seen)
AssemblyLister.Lister.DeepWalkReferences (System.Reflection.Assembly assembly, System.Collections.Generic.HashSet1 seen)
AssemblyLister.Lister+<>c__DisplayClass1_0.<get_AllAssemblies>b__0 (System.Reflection.Assembly asm)
System.Linq.Enumerable+<CreateSelectManyIterator>c__Iterator12
2[System.Reflection.Assembly,System.Reflection.Assembly].MoveNext ()
System.Linq.Enumerable+c__Iterator122[System.Reflection.Assembly,LeanCloud.Storage.Internal.AVModuleAttribute].MoveNext ()
System.Linq.Enumerable+<CreateSelectIterator>c__Iterator10
2[LeanCloud.Storage.Internal.AVModuleAttribute,System.Type].MoveNext ()
System.Linq.Enumerable+c__Iterator1D`1[System.Type].MoveNext ()
LeanCloud.Storage.Internal.AVModuleController.ScanForModules ()
LeanCloud.AVClient..cctor ()
Rethrow as TypeInitializationException: An exception was thrown by the type initializer for LeanCloud.AVClient
LeanCloud.AVInitializeBehaviour.Initialize ()
LeanCloud.AVInitializeBehaviour.Awake ()

Unity2017.3.1正常,升级至2018.1后报错
Unity中使用.net 3.5 .net 2.0sub
聊天SDK v20180510 .net3.5版本

这个是 Unity 新版的 bug,原因是由于 Unity 运行时的程序集包含某些模块,但是有些模块在新版中已经被删除了,我们针对这种「Unity 意外情况」已经打了 SDK 补丁,请下载新版 SDK。
SDK 下载8

FileNotFoundException: Could not load file or assembly 'AssemblyLister, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies.
LeanCloud.AVClient..cctor ()
Rethrow as TypeInitializationException: An exception was thrown by the type initializer for LeanCloud.AVClient
LeanCloud.AVInitializeBehaviour.Initialize ()
LeanCloud.AVInitializeBehaviour.Awake ()
UnityEngine.GameObject:AddComponent()
LeanCloud.Realtime.AVRealtimeBehavior:OnRuntimeMethodLoad()

替换v20180515.1后出现新的报错
3.5文件列表如下

LeanCloud.Core.dll
LeanCloud.Realtime.dll
LeanCloud.Storage.dll
link.xml
Unity.Compat.dll
Unity.Tasks.dll
UnityEngine.dll
websocket-sharp.dll

更新v20180515.3后,出现如下报错,请确认

FileNotFoundException: Could not load file or assembly 'UnityEngine.ClusterInputModule' or one of its dependencies. The system cannot find the file specified.
System.AppDomain.Load (System.Reflection.AssemblyName assemblyRef, System.Security.Policy.Evidence assemblySecurity) (at /Users/builduser/buildslave/mono/build/mcs/class/corlib/System/AppDomain.cs:692)
(wrapper remoting-invoke-with-check) System.AppDomain:Load (System.Reflection.AssemblyName,System.Security.Policy.Evidence)
System.AppDomain.Load (System.Reflection.AssemblyName assemblyRef) (at /Users/builduser/buildslave/mono/build/mcs/class/corlib/System/AppDomain.cs:657)
(wrapper remoting-invoke-with-check) System.AppDomain:Load (System.Reflection.AssemblyName)
System.Reflection.Assembly.Load (System.Reflection.AssemblyName assemblyRef) (at /Users/builduser/buildslave/mono/build/mcs/class/corlib/System.Reflection/Assembly.cs:589)
AssemblyLister.Lister.DeepWalkReferences (System.Reflection.Assembly assembly, System.Collections.Generic.HashSet1 seen)
AssemblyLister.Lister.DeepWalkReferences (System.Reflection.Assembly assembly, System.Collections.Generic.HashSet
1 seen)
AssemblyLister.Lister.DeepWalkReferences (System.Reflection.Assembly assembly, System.Collections.Generic.HashSet1 seen)
AssemblyLister.Lister+<>c__DisplayClass1_0.<get_AllAssemblies>b__0 (System.Reflection.Assembly asm)
System.Linq.Enumerable+<CreateSelectManyIterator>c__Iterator12
2[System.Reflection.Assembly,System.Reflection.Assembly].MoveNext ()
System.Linq.Enumerable+c__Iterator122[System.Reflection.Assembly,LeanCloud.Storage.Internal.AVModuleAttribute].MoveNext ()
System.Linq.Enumerable+<CreateSelectIterator>c__Iterator10
2[LeanCloud.Storage.Internal.AVModuleAttribute,System.Type].MoveNext ()
System.Linq.Enumerable+c__Iterator1D`1[System.Type].MoveNext ()
LeanCloud.Storage.Internal.AVModuleController.ScanForModules ()
LeanCloud.AVClient..cctor ()
Rethrow as TypeInitializationException: An exception was thrown by the type initializer for LeanCloud.AVClient
LeanCloud.AVInitializeBehaviour.Initialize ()
LeanCloud.AVInitializeBehaviour.Awake ()
UnityEngine.GameObject:AddComponent()
LeanCloud.Realtime.AVRealtimeBehavior:OnRuntimeMethodLoad()

3.5文件列表

AssemblyLister.dll
LeanCloud.Core.dll
LeanCloud.Realtime.dll
LeanCloud.Storage.dll
link.xml
Unity.Compat.dll
Unity.Tasks.dll
UnityEngine.dll
websocket-sharp.dll

md5(AssemblyLister.dll) = a37c8987c2ec81e0ff0192487a11a29f

之前的问题解决了,又出现了新问题

NullReferenceException: Object reference not set to an instance of an object
LeanCloud.AVClient.Initialize (Configuration configuration)
LeanCloud.AVInitializeBehaviour.Initialize ()
LeanCloud.AVInitializeBehaviour.Awake ()
UnityEngine.GameObject:AddComponent()
LeanCloud.Realtime.AVRealtimeBehavior:OnRuntimeMethodLoad()

新建场景 不挂载任何脚本,运行报错。

你需要挂载一个 AVInitializeBehaviour 脚本,并填写你申请的 App ID 和 App Key

不同项目有自己的生命周期管理,我们项目并不希望第一个场景就挂载这个脚本,而是希望通过动态加载的形式创建出来。

代码我反编译看了,AVRealtimeBehavior不管我是否预先挂载了脚本,它会自己强行创建一个GameObject,并挂载脚本,且不受管理。这种方式不报错的原因也只是因为有一个flag判断已经初始化则不往下走。

希望能够去掉这个特性。

嗯,我明白你的意思了,我们内部讨论一下,稍后给出结论。

谢谢你的建议
经过我们讨论,已经参考你的建议对 AVRealtime 的初始化进行了调整。
即 在需要的时候,通过 AddComponent() 进行初始化。
请下载 最新SDK1

已确认修复!

此外,关于AVRealtimeBehavior,我们的习惯用法如下:

using LeanCloud;
using LeanCloud.Realtime;
using UnityEngine;
public class MyAVRealtimeBehavior:AVRealtimeBehavior
{
private static MyAVRealtimeBehavior Instance;
public static void Init( bool useProduction, string applicationID, string applicationKey, AVClient.Configuration.AVRegion region,
string engineServer )
{
if( Instance == null )
{
var go = new GameObject();
Instance = go.AddComponent();
Instance.useProduction = useProduction;
Instance.applicationID = applicationID;
Instance.applicationKey = applicationKey;
Instance.region = region;
Instance.engineServer = engineServer;
Instance.Init();
}
}
public override void Awake()
{ }
private void Init()
{
base.Awake();
}
}

理解你这么写有点别扭,我们之前是希望在场景中预先挂载 AVRealtimeBehavior 进行初始化的。
针对你的需求,有些思路可以借鉴一下(不适用继承,而是组合)

可以初始化一个 InActive 的 GameObject 上挂载 AVRealtimeBehavior 脚本;或者从 Resources 中加载一个挂载好的预制体。

总之,利用 InActive 的特点,控制 Awake() 的调用时机。

由于相关的Key都是动态配置文件,所以不太适合用Resources,不过使用InActive的特性确实更为简洁,谢谢提醒!