帝国cms建站系统,微信网站怎样做,做电影网站需要空间吗,网站建设存在四个问题创建场景
创建新的场景后#xff1a; 文件 - 生成设置 - Build中的场景 - 将项目中需要使用的场景拖进去 SceneTest
public class SceneTest : MonoBehaviour
{// Start is called before the first frame updatevoid Start(){// 两个类#xff1a; 场景类、场…创建场景
创建新的场景后 文件 - 生成设置 - Build中的场景 - 将项目中需要使用的场景拖进去 SceneTest
public class SceneTest : MonoBehaviour
{// Start is called before the first frame updatevoid Start(){// 两个类 场景类、场景管理类// 场景类// 获取当前场景Scene scene SceneManager.GetActiveScene();// 场景名称Debug.Log(scene.name);// 场景是否已经加载Debug.Log(scene.isLoaded);// 场景路径Debug.Log(scene.path);// 场景在build中的场景中的索引号Debug.Log(scene.buildIndex);// 获取场景中的所有物体不包括子物体GameObject[] gos scene.GetRootGameObjects();Debug.Log(gos.Length);// 场景管理类// 【场景加载】 场景同步加载使用在build中的场景中的索引号加载SceneManager.LoadScene(1);// 【场景加载】 使用场景名称加载SceneManager.LoadScene(MyScene);// 【场景加载】 单一场景加载, 加载后只存在一个场景SceneManager.LoadScene(MyScene, LoadSceneMode.Single);// 【场景加载】 融合场景加载加载后与之前场景重叠在一起, 但如果场景多会卡顿要使用异步加载SceneManager.LoadScene(MyScene, LoadSceneMode.Additive);// 【创建场景】创建新的场景Scene newScene SceneManager.CreateScene(NewScene);// 【场景数量】当前已经加载的场景数量Debug.Log(SceneManager.sceneCount);// 【卸载场景】场景异步销毁SceneManager.UnloadSceneAsync(newScene);}// Update is called once per framevoid Update(){}
}
场景异步加载----协程
AsyncTest
public class AsyncTest : MonoBehaviour
{private AsyncOperation operation;private float timer 0;void Start(){// 【调用协程】 使用该函数来使用协程StartCoroutine(loadScene());}// 【协程】 使用协程方法来异步加载场景IEnumerator loadScene(){// 异步加载场景,使用索引号operation SceneManager.LoadSceneAsync(1);// 加载完成场景后不会自动跳转, 可自己加计时器来控制跳转operation.allowSceneActivation false;yield return operation;}void Update(){// 【加载进度】 输出加载进度0-0.9 Debug.Log(operation.progress);// 使用计时器来控制场景跳转, 5秒后跳转timer Time.deltaTime;if (timer 5){operation.allowSceneActivation true;}}
}