unity3D密碼框無法識別char的問題
今天在畫密碼框的時候,按照幫助里的寫法會報錯,錯誤信息為:unexpected char: ''' 。百思不得其解。
這是幫助里的示例:
var passwordToEdit = "My Password";
function OnGUI () {
// Make a password field that modifies passwordToEdit.
passwordToEdit = GUILayout.PasswordField (passwordToEdit, '*', 25);
}
function OnGUI () {
// Make a password field that modifies passwordToEdit.
passwordToEdit = GUILayout.PasswordField (passwordToEdit, '*', 25);
}
估計這是Unity3D本身的問題,不認識單引號表示的char的方式。靜下心思考后,想起了一個變通的辦法解決了這個問題。代碼如下:
var passwordToEdit = "My Password";
function OnGUI () {
// Make a password field that modifies passwordToEdit.
passwordToEdit = GUILayout.PasswordField (passwordToEdit, "*"[0], 25);
}
function OnGUI () {
// Make a password field that modifies passwordToEdit.
passwordToEdit = GUILayout.PasswordField (passwordToEdit, "*"[0], 25);
}