Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/unity3d/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 输入字段统一中的粘贴问题_C#_Unity3d - Fatal编程技术网

C# 输入字段统一中的粘贴问题

C# 输入字段统一中的粘贴问题,c#,unity3d,C#,Unity3d,我遇到了一个无法继续的场景,实际上我有一个输入字段,在该字段中,我应该能够识别通过cmd+v粘贴数据的用户,因为我有一个填充代码 public InputField _wordsEntry; if ( (Input.GetKey(KeyCode.RightCommand) || Input.GetKey(KeyCode.LeftCommand)) && Input.GetKeyDown(KeyCode.V) || Input.GetMouseButtonUp(1))

我遇到了一个无法继续的场景,实际上我有一个输入字段,在该字段中,我应该能够识别通过
cmd+v
粘贴数据的用户,因为我有一个填充代码

 public InputField _wordsEntry;

    if ( (Input.GetKey(KeyCode.RightCommand) || Input.GetKey(KeyCode.LeftCommand)) && Input.GetKeyDown(KeyCode.V) || Input.GetMouseButtonUp(1))
            {

                if (EventSystem.current.currentSelectedGameObject != null && EventSystem.current.currentSelectedGameObject.name == "WordsEntry")
                {                   
                    if (string.IsNullOrEmpty(_wordsEntry.text))
                        _wordsEntry.text =ClipboardHelper.Clipboard;
                    else
                        _wordsEntry.text = _wordsEntry.text + '\n' + ClipboardHelper.Clipboard;
                    _wordsEntry.MoveTextEnd(false);
                }
            }

问题是
if(string.IsNullOrEmpty(\u wordsEntry.text))
此条件始终变为false。当我尝试将复制的内容粘贴到
else
条件时,是否缺少任何内容

事实上,我很确定这就是答案,所以我将我的评论转换为答案xd

试着这样做:

String.IsNullOrEmpty(_wordsEntry.text) //(capital S)
_wordsEntry.text.IsNullOrEmpty()
或者像这样:

String.IsNullOrEmpty(_wordsEntry.text) //(capital S)
_wordsEntry.text.IsNullOrEmpty()

请这样尝试:“String.IsNullOrEmpty(_wordsEntry.text)”(大写字母S)或类似于:“_wordsEntry.text.IsNullOrEmpty()”感谢@Lestat的帮助,我尝试了第一种取S的方法,但这对我不起作用,第二种情况不允许。该值在粘贴到输入字段之前为文本赋值。