private Action prgCB = null;
public void AsyncLoadScene(string scenename, Action action)
{
print("异步加载场景:" + scenename);
AsyncOperation operation = SceneManager.LoadSceneAsync(scenename);
prgCB = () =>// lamada 表达
{
float val = operation.progress;
if (val == 1)
{
if (action != null)
{
action();
}
operation = null;
prgCB = null;
}
};
}
private void Update()
{
if (prgCB != null)
{
prgCB();
}
}