I am trying to use parse.com service with my unity game. My problem is instantiating objects according to the results received from a query.
For example, when I run the below code;
var queryCurrent = ParseObject.GetQuery("Levels")
.WhereEqualTo("ItemId", "Character")
.WhereEqualTo("Level", "3");
queryCurrent.FirstAsync().ContinueWith(t =>
{
Character character = ScriptableObject.CreateInstance<Character>();
});
I receive the following error;
CreateInstanceFromType 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.
It seems that this is a general problem and everyone tries to find a workaround by using coroutines. An optimized solution will be appreciated.
Thanks in advance.