Unity数字小区项目-3、登录界面跳转场景
粥稀稀的:
using UnityEngine;
using System.Collections;
using UnityEngine.UI;
public class Login: MonoBehaviour
{
public InputField input_Name;//用户名
public InputField input_Pw;//密码
// Use this for initialization
void Start()
{
}
// Update is called once per frame
void Update() {
}
public void Btn_Login()
{
if (input_Name.text=="" input_Pw.text=="")
{
print("用户名或者密码不能为空!");
} else if (input_Name.text == "admin" && input_Pw.text == "123")
{
print("登录成功");
UnityEngine.SceneManagement.SceneManager.LoadScene(1);
} else{
print("你的用户名或者密码不正确!");
}
}
}//UP主你好,我根据视频敲的代码,但总是报错,请问可以抽空看一下吗?
【回复】是不是或者符没有写的问题
【回复】回复 @曦鬼丶 :判断等于null怎么样[吃瓜]
【回复】少了两个 | | 这个符号在 if (input_Name.text == "" || input_Pw.text == "")
Twelve哎吆歪:
Up主,请问我出现了路径的共享冲突怎么办吖
鹿畔畔:
up主[星星眼]为什么我的声明input在int里不显示啊[笑哭]
【回复】看看输入文本框的颜色问题
连袂-:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class Login : MonoBehaviour {
/// <summary>
/// 登录界面UI
/// </summary>
public InputField input_Name;//用户名
public InputField input_Pw;//密码
// Start is called before the first frame update
void Start() {
}
// Update is called once per frame
void Update() {
}
public void Btn_Login()
{
if (input_Name.text == ""||input_Pw.text == "")
{
print("用户名或者密码不能为空!");
} else if (input_Name.text == "hnnzxy"&&input_Pw.text == "123456")
{
print("登录成功");
UnityEngine.SceneManagement.SceneManager.LoadScene(1);
} else{
print("你的用户名或密码不正确!");
}
}
}
up主,这代码哪里有问题啊,一直运行不了[大哭][大哭][大哭]周五要交作业了[大哭][大哭][大哭][大哭]
阿航工作室:
为什么跳转场景是LoadScene(1),你的第二个场景不是叫Lv02吗
【回复】可以用名字,我用的是索引
十一-h:
UP主,我想问一下,我这里照着你的代码打,显示操作符&&不能应用于类型为“bool”和“string”的操作数,我该怎么做呀[委屈]
【回复】你可以看看源码,源码怎么写的,我感觉你应该是写错了
【回复】可以看看源码,编译一下看看那里出错了
大猫SUDA_:
up主,为什么我的输入框拖不到脚本里?
叮叮车起飞了:
你这个只是显示在控制台里,怎么把用户名或密码错误这些显示在ui上
阳虞啊:
我的为什么跳转不了啊[保卫萝卜_哭哭]