https://fogbugz.unity3d.com/default.asp?1143604_v8qe8bvth3mn1iog.
- What happened
The asynchronous function callback method is passed from the Play mode to the Editor mode.
Expected behavior: Forced to stop all asynchronous functions when switching Editor/Play mode.
- How we can reproduce it using the example you attached
Play SampleScene, Stop Play mode. Wait for 10s and will create a cube in the current scene in editor mode. It’s wrong.
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using System.Threading.Tasks;
public class AsyncBug : MonoBehaviour
{
// Start is called before the first frame update
async void Start()
{
Debug.Log(1);
await Task.Delay(10000);
Debug.Log(2);
GameObject go = GameObject.CreatePrimitive(PrimitiveType.Cube);
Debug.Log(3);
}
}