Error: CompareBaseObjectsInternal can only be called from the main thread
Posted lytwajue
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Error: CompareBaseObjectsInternal can only be called from the main thread相关的知识,希望对你有一定的参考价值。
hi, we’re working on a project where we need to do some calculations on a separate thread. The data we need for the calculations is stored on a scriptable object. We use the scriptable object so that we can serialize the data and save it as an asset file. However, when we tried to access the data from a separate thread we get the following error.
CompareBaseObjectsInternal can only be called from the main thread.
Constructors and field initializers will be executed from the loading thread when loading a scene.
Don‘t use this function in the constructor or field initializers, instead move initialization code to the Awake or Start function.
For our purposes we only need to read the data. One of the things that we tried to do to get around this was to use an interface. It appears that if you use an interface as a reference to the object then you’re able to access the data without getting that error. For example
Code:
{ } List<Node> dataset; .. // Error, this fails inside of thread Node node = dataset[i];
this works:
Code:
public interface INodeData { } { } List<INodeData> dataset; .. // this works! inside of thread INodeData node = dataset[i];
以上是关于Error: CompareBaseObjectsInternal can only be called from the main thread的主要内容,如果未能解决你的问题,请参考以下文章
新浪微博Error_code: 400; Error: 40022:Error: source paramter(appkey) is missing的解决方法
Error 500--Internal Server Error如何解决
在 MySQL 中出现 ERROR 1701、ERROR 1452 和 ERROR 1305 错误 - 需要一些专业知识