无效的表达式术语')'

问题描述 投票:0回答:0

我收到一个错误信息

Assets\Scripts\PlayerNameInputField.cs(24,80): error CS1525: Invalid expression term ')

我的代码是这样的

using UnityEngine;
using UnityEngine.UI;
using Photon.Pun;
using Photon.Realtime;
using System.Collections;

namespace Joshua.RacingGame
{
    [RequireComponent(typeof(InputField))]
    public class PlayerNameInputField : MonoBehaviour
    {
        #region Private Constants

        const string playerNamePrefKey = "PlayerName";

        #endregion

        #region MonoBehaviour CallBacks

        void Start()
        {

            string defaultName = string.Empty;
            InputField _inputField = this.GetComponent & lt; InputField & gt; ();
            if (_inputField != null)
            {
                if (PlayerPrefs.HasKey(playerNamePrefKey))
                {
                    defaultName = PlayerPrefs.GetString(playerNamePrefKey);
                    _inputField.text = defaultName;
                }
            }

            PhotonNetwork.NickName = defaultName;
        }

        #endregion

        #region Public Methods


        public void SetPlayerName(string value)
        {
            if (string.IsNullOrEmpty(value))
            {
                Debug.LogError("Player Name is null or empty");
                return;
            }
            PhotonNetwork.NickName = value;

            PlayerPrefs.SetString(playerNamePrefKey, value);
        }

        #endregion
    }


}

我还以为是建议我拆支架

我试过删除它所指的括号,但这并不能解决问题,它只会产生更多错误。

谢谢你的帮助

c# unity3d photon photon-pun
© www.soinside.com 2019 - 2024. All rights reserved.