Quantcast
Channel: Questions in topic: "error"
Viewing all articles
Browse latest Browse all 7934

get_enabled can only be called from the main thread.

$
0
0
Hey there, I'm getting this error, and I can't understand why. > get_enabled 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. Here is my code: using UnityEngine; using UnityEngine.UI; using System.Collections; using Parse; public class HSManagerN : MonoBehaviour { public int skip = 0; void Awake () { Text text; text = GetComponent (); //This is what is causing the error var query = ParseObject.GetQuery("GameScore") .OrderBy("CreatedAt") .ThenByDescending("Score"); query = query.Skip(skip); query.FirstAsync().ContinueWith(t => { ParseObject obj = t.Result; text.text = obj.Get("Name"); }); } void Update () { } } I have the GetComponent in the awake function, but i'm still getting this error. Does anyone know why this is happening? Thanks for the help =)

Viewing all articles
Browse latest Browse all 7934

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>