void LoadFromStream(StreamReader reader) { // Create OBJ reader ObjReader objReader = new ObjReader(); Vector3 [][] polylines = objReader.GetPolylinesFromStreamReader(reader); // Make sure to lock to avoid multithreading problems lock (_enque) { // Run the generation of polylines in the Main Thread ExecuteOnMainThread.Enqueue(() => { StartCoroutine(AfterLoading()); }); ExecuteOnMainThread.Enqueue(() => { StartCoroutine(Generate(polylines)); }); }; }