请问关于c的具体应用场景有哪些?

2026-04-29 03:413阅读0评论SEO资讯
  • 内容介绍
  • 文章标签
  • 相关推荐

本文共计294个文字,预计阅读时间需要2分钟。

请问关于c的具体应用场景有哪些?

当点击一个按钮时,它在OnClick中调用方法ActivatePlayer:using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.SceneManagement; public class LoadSceneOnClick : MonoBehaviour { private “}

当我点击一个按钮时,它在On Click中调用方法ActivatePlayer:

using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.SceneManagement; public class LoadSceneOnClick : MonoBehaviour { private Scene scene; private void Start() { scene = SceneManager.GetActiveScene(); StartCoroutine(WaitForSceneUnLoad(SceneManager.GetSceneByName("The Space Station"))); } public IEnumerator WaitForSceneUnLoad(Scene scene) { return null; } public void ActivatePlayer() { SceneManager.UnloadSceneAsync(0); Cursor.visible = false; GameControl.player.SetActive(true); } }

但现在我想等待UnloadSceneAsync首先完成这一行:

SceneManager.UnloadSceneAsync(0);

只有当它完成卸载时,其余两行:

请问关于c的具体应用场景有哪些?

Cursor.visible = false; GameControl.player.SetActive(true);

问题是,当我单击按钮时,我仍然会看到场景index0的第二个gui元素.索引中的场景是主菜单,当我单击按钮一秒钟时,我会看到主菜单文本的一部分.在卸载主菜单之前,它似乎正在激活播放器.由于主菜单和播放器都有摄像头的场景,我看到主菜单一秒钟.

尝试将您的脚本放在IEnumerator中

public void ActivatePlayer() { StartCoroutine(StartActivatePlayer()); } IEnumerator StartActivatePlayer() { AsyncOperation ao = SceneManager.UnloadSceneAsync(0); yield return ao; Cursor.visible = false; GameControl.player.SetActive(true); }

希望它有所帮助.

本文共计294个文字,预计阅读时间需要2分钟。

请问关于c的具体应用场景有哪些?

当点击一个按钮时,它在OnClick中调用方法ActivatePlayer:using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.SceneManagement; public class LoadSceneOnClick : MonoBehaviour { private “}

当我点击一个按钮时,它在On Click中调用方法ActivatePlayer:

using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.SceneManagement; public class LoadSceneOnClick : MonoBehaviour { private Scene scene; private void Start() { scene = SceneManager.GetActiveScene(); StartCoroutine(WaitForSceneUnLoad(SceneManager.GetSceneByName("The Space Station"))); } public IEnumerator WaitForSceneUnLoad(Scene scene) { return null; } public void ActivatePlayer() { SceneManager.UnloadSceneAsync(0); Cursor.visible = false; GameControl.player.SetActive(true); } }

但现在我想等待UnloadSceneAsync首先完成这一行:

SceneManager.UnloadSceneAsync(0);

只有当它完成卸载时,其余两行:

请问关于c的具体应用场景有哪些?

Cursor.visible = false; GameControl.player.SetActive(true);

问题是,当我单击按钮时,我仍然会看到场景index0的第二个gui元素.索引中的场景是主菜单,当我单击按钮一秒钟时,我会看到主菜单文本的一部分.在卸载主菜单之前,它似乎正在激活播放器.由于主菜单和播放器都有摄像头的场景,我看到主菜单一秒钟.

尝试将您的脚本放在IEnumerator中

public void ActivatePlayer() { StartCoroutine(StartActivatePlayer()); } IEnumerator StartActivatePlayer() { AsyncOperation ao = SceneManager.UnloadSceneAsync(0); yield return ao; Cursor.visible = false; GameControl.player.SetActive(true); }

希望它有所帮助.