跨场景查找获取物体

    IEnumerator LoadOtherSceneObj()
    {
        //加载场景
        AsyncOperation operation = SceneManager.LoadSceneAsync(1, LoadSceneMode.Additive);
        yield return operation;
        //获取场景
        Scene gameScene = SceneManager.GetSceneByBuildIndex(1);
        //查找物体
        GameObject mainCanvas = gameScene.GetRootGameObjects().FirstOrDefault(x => x.name == "MainCanvas");
        //
        foreach (Button btn in mainCanvas.GetComponentsInChildren

 

你可能感兴趣的:(问题记录)