title: Using async await in Unity
body: <p>Someone can say how to make such a construction work? Currently returns UnityExtension.
  Well, or advise how easy it is to move a part of the non-MonoBehaviour code into a separate thread.</p>
  <blockquote>
  <p>UnityException: get_canAccess 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.</p>
  </blockquote>
  <pre><code>    private async void Awake()
      {
          Mesh protoMesh = gameObject.GetComponent&lt;MeshFilter&gt;().mesh;
          SelfMesh = await InitMeshAsync(protoMesh);
      }
  
      protected async Task&lt;CustomMesh&gt; InitMeshAsync(Mesh protoMesh)
      {
          return await Task.Run(() =&gt; new CustomMesh(protoMesh.vertices, protoMesh.triangles));
      }
  </code></pre>