Hello, I'm really hoping I can get help here, but this question is a combination of tk2d and the Parse library (for databasing). Anyways, here is my code.
ParseQuery<ParseObject> query = ParseObject.GetQuery("GameScore");
textMesh = GetComponent<tk2dTextMesh>();
string str = " ";
query.FindAsync().ContinueWith(t =>
{
IEnumerable<ParseObject> results = t.Result;
foreach (var result in results) {
//var textMesh = GetComponent<tk2dTextMesh>();
//var textMesh = Component<tk2dTextMesh>();
Debug.Log("Score: " + result["score"] + " and Name: " + result["playerName"]);
int temp = result.Get<int>("score");
str += "Score: " + temp.ToString();
str += "Name: " + result.Get<string>("playerName");
Debug.Log("Got here");
1 textMesh.text += "Score: " + temp.ToString();
Debug.Log("Got here");
2 textMesh.Commit();
Now, my problem is when I try to write text to the textMesh and commit it.
I get some weird error "get_isPlaying 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."
BUT I know that it is the textMesh method, because when I move it or comment it out, the error disappears. What I am trying to do, is get my high scores from my parse database, and display them in the textMesh. The string I used to try and compound the text i want, and then add that string to the textMesh after the foreach loop, but the data is null afterwards.
The debug that displays the score and name from result does display properly, so i know that the data is coming in.