Hey!
Does anybody know what this error means?
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.
What I try to do is run a function inside a thread.
In this function I compare a variable inside one class to a variable of another class. Values are initialized by constructors before the function is even called.
I don’t seem to be using any of unity’s API. no calls similar to gameObject.name or getComponent() are there.
NODE COUNTER EDITOR
//NodeCounterEditor
//folowing function gets called from the OnInspectorGUI, get's fed a class LookFurtherArgs with 3 starting parameters
void LookFurther(object _work){
LookFurtherargs _recieved = (LookFurtherargs)_work;
GameObject currentNode = _recieved.current;
GameObject cameFrom = _recieved.camefrom;
NodeSpark _NScurrentNode = (NodeSpark)_recieved.carriedScript;
if(remoteAdv > 0){
//do something
for(int x = 0; x < _NScurrentNode.neighbours.Count; x++){
//do something else
if(!BanCheck(check1) && check1 != cameFrom ){ //PROBLEMATIC AREA, BanCheck is a function returns true/false, not the cause of problem though.
remoteAdv--;
object _inPass = new LookFurtherargs(_NScurrentNode.neighbours[x],currentNode,_NScurrentNode._NSneighbour[x]);
LookFurther(_inPass); //continue recursion with the neighbor that is available to explore
remoteAdv++;
}
}//end of if
}//end of function
LookFurtherArgs. used as a feeding object for a function LookFurther, that has to take 3 parameters, but thread only allows object, so we are using this class to shove it in that thread
using UnityEngine;
using System.Collections;
public class LookFurtherargs {
public GameObject current;
public GameObject camefrom;
public NodeSpark carriedScript;
public LookFurtherargs(GameObject x, GameObject c, NodeSpark j){
current = x;
camefrom = c;
carriedScript = j;
}//end of constructor
public NodeSpark component(GameObject a){
return a.GetComponent<NodeSpark>();
}
}
finally, NodeSpark
using UnityEngine;
using System.Collections;
using System.Collections.Generic;
public class NodeSpark : MonoBehaviour {
public List<GameObject> neighbours = new List<GameObject>();
public List<string> accessN;
public List<BranchShell> pathHolder = new List<BranchShell>();
public List<NodeSpark> _NSneighbour = new List<NodeSpark>();
public string carriedName; //simmilar to the one below
public GameObject GO; //get's a value from NodeSparkEditor, during OnEnable(), through target as GameObject
}//end of class