void LoadFromFile() { // Create OBJ reader ObjReader objReader = new ObjReader(); Vector3 [][] polylines = objReader.GetPolylinesFromFilePath(path); // 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)); }); }; }