[2021.10.25]<呆头熊的开发日记>UI界面&场景切换
作者:互联网
主美把登陆界面和各种按钮都画好了,国风水墨的感觉超级好看!!!
我们主美YYDS!!!
登陆界面:
1.添加UI---Canvas---Image
2.添加Buttun
3.写Scripts(场景转换)
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.SceneManagement;
public class MainMenu : MonoBehaviour
{
public void PlayGame()
{
SceneManager.LoadScene(SceneManager.GetActiveScene().buildIndex + 1);
}
public void QuitGame()
{
Application.Quit();
}
}
4.将MainMenu场景建立在:文件---Build Settings
5.调节Buttun中设置,调用脚本函数:
场景切换跟上面差不多,不同的是在关卡中设置了一个【触发器】实现场景切换:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.SceneManagement;
public class Door : MonoBehaviour
{
void OnTriggerEnter2D(Collider2D other)
{
if (other.gameObject.CompareTag("Player") && other.GetType().ToString() == "UnityEngine.CapsuleCollider2D")
{
SceneManager.LoadScene(SceneManager.GetActiveScene().buildIndex + 1); //场景+1
}
}
}
补充:做粒子效果的时候,想做成许多粒子由外向内聚集的效果,就把Start Speed改成负数就可以了。再调调Shape。
标签:25,UnityEngine,场景,呆头,2021.10,System,Collections,using,public 来源: https://blog.csdn.net/qq_40328494/article/details/121004859