UI分数
using UnityEngine.UI;//引用命名空间
public int 分数;
public Text Text;
public int 最大数;
void Start()
{
int i = PlayerPrefs.GetInt("dd", 0);//读取数据
Debug.Log(i);
}
void Update()
{
if (Input.GetMouseButtonDown(0))//鼠标左键点击加分
{
分数++;
Text.text = "分数:"+分数.ToString();//转为字符串类型
}
SetScore();//持续调用获取分数
}
public void SetScore()
{
if (分数> 最大数)//如果分数大于最大数
{
最大数 = 分数;//最大数等于分数
PlayerPrefs.SetInt("dd", 最大数);//存储最大数
}
}
账号密码InputField
using UnityEngine.UI;//引用命名空间
public InputField 账号;//可以输入的 InputField
public InputField 密码;
private void Update()
{
if (账号.text == "123" && 密码.text == "123")
{
Debug.Log("欢迎来到王者荣耀");
}
}