?1.創(chuàng)建UI面板
導(dǎo)入插件TextMesh Pro?
2.編寫(xiě)腳本獲取用戶輸入
這里用的是輸入框偵聽(tīng)函數(shù),所有UI都可以使用偵聽(tīng)函數(shù)?,需要注意TMP_InputField 這個(gè)類是UI中導(dǎo)入的一個(gè)插件TextMesh Pro!在代碼中需要引用using TMPro; 命名空間!
下面是代碼:文章來(lái)源:http://www.zghlxwxcb.cn/news/detail-757781.html
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using TMPro;
using UnityEditor;
using System;
//該腳本1.獲取場(chǎng)景中輸入框組件2.獲取用戶輸入內(nèi)容
public class LOginUIControl : MonoBehaviour
{
string UserAccount;
string UserPassWord;
public TMP_InputField InputAccount;
public TMP_InputField InputPassWord;
void Start()
{
InputAccount.onEndEdit.AddListener(OnUserInputAccount);
InputPassWord.onEndEdit.AddListener(OnUserInputPassWord);
}//end start
private void OnUserInputPassWord(string userPassWord)
{
UserPassWord = userPassWord;
Debug.Log("UserPassWord:"+ UserPassWord);
}
private void OnUserInputAccount(string Account)
{
UserAccount = Account;
Debug.Log("UserAccount:" + UserAccount);
}
}//end class
?文章來(lái)源地址http://www.zghlxwxcb.cn/news/detail-757781.html
到了這里,關(guān)于Unity 制作登錄功能01-創(chuàng)建登錄的UI并獲取輸入內(nèi)容的文章就介紹完了。如果您還想了解更多內(nèi)容,請(qǐng)?jiān)谟疑辖撬阉鱐OY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章,希望大家以后多多支持TOY模板網(wǎng)!