C#)预期错误? [英] C# ) expected error?

查看:72
本文介绍了C#)预期错误?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我对C#很新,我不明白这个问题,请帮忙。





使用System.Collections;

使用System.Collections.Generic;

使用UnityEngine;



公共类PlayerControlelr:MonoBehaviour {



public float moveSpeed;





void Start(){



}



//每帧调用一次更新

void Update(){

if(Input.GetAxisRaw(Horizo​​ntal)> 0.5f)



Transform.Translate(new Vector3(Input.GetAxisRaw) (水平)* moveSpeed * Time.deltaTime,0f,0f);< - 这里是错误出现的地方









if(Input.GetAxisRaw(Vertical)> 0.5)





{

} {

}}}



我有什么尝试过:



我已经尝试过放更多的东西了(在那里,它不断出现

解决方案

算上括号:

 Transform.Translate(new Vector3(Input.GetAxisRaw(Horizo​​ntal)* moveSpeed * Time.deltaTime,0f,0f); 
.................... 1 ........... 2 ............. ... 3 ............ 3 ................................. .... 2

您缺少要关闭的括号(1)。我怀疑它应该是:

 Transform.Translate(new Vector3(Input.GetAxisRaw(Horizo​​ntal)* moveSpeed * Time.deltaTime,0f,0f)); 

但这取决于你使用的是哪种方法。



提示:如果你把输入光标放在VS的一个关闭括号后面,它会突出显示它的匹配打开支架。



哦,那条线上方的开放式支架也应该是一个开放的花括号。



最后!得到了愚蠢的数字... [/ edit]


建议:使用专业程序员的编辑器,它们加载了对程序员有用的功能:

- 适当的缩进,它有助于查看程序结构,有助于发现一些错误。

- 括号匹配,当光标在括号上时,匹配的一个突出显示。此功能有助于发现代码中的错误。

 使用 System.Collections; 
使用 System.Collections.Generic;
使用 UnityEngine;

public class PlayerControlelr:MonoBehaviour {

public float moveSpeed;
void Start(){
}
// 每帧调用一次更新
void 更新(){
if (Input.GetAxisRaw( Horizo​​ntal> 0 .5f)

Transform.Translate( new Vector3(Input.GetAxisRaw( Horizo​​ntal)* moveSpeed * Time.deltaTime,0f,0f);< - 此处 其中错误出现

if (Input.GetAxisRaw( 垂直> 0 5
{
}
{
}
}
}



Notepad ++ Home [ ^ ]

UltraEdit |原始文本编辑器 [ ^ ]



 //  <  - 左括号在这一行是无与伦比的,我本来期望一个卷曲的。 
Transform.Translate( new Vector3(Input.GetAxisRaw( 水平)* moveSpeed * Time.deltaTime,0f,0f);


im very new to C# and i do not understand the issue here, please help.


using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class PlayerControlelr : MonoBehaviour {

public float moveSpeed;


void Start () {

}

// Update is called once per frame
void Update () {
if(Input.GetAxisRaw("Horizontal") > 0.5f)
(
Transform.Translate (new Vector3(Input.GetAxisRaw("Horizontal") * moveSpeed * Time.deltaTime, 0f, 0f);<- right here is where the error comes up




if(Input.GetAxisRaw("Vertical") > 0.5)


{
}{
}}}

What I have tried:

ive tried putting more )'s there and ('s there and it keeps coming up

解决方案

Count the brackets:

Transform.Translate (new Vector3(Input.GetAxisRaw("Horizontal") * moveSpeed * Time.deltaTime, 0f, 0f);
....................1...........2................3............3.....................................2

You are missing the bracket to close (1). I suspect it should be:

Transform.Translate (new Vector3(Input.GetAxisRaw("Horizontal") * moveSpeed * Time.deltaTime, 0f, 0f));

But it depends which methods you are using.

Hint: If you put the input cursor after a close bracket in VS, it highlights it's matching open bracket.

Oh, and the open bracket above that line should be an open curly bracket as well.

[edit]Finally! Got the stupid numbers lined up...[/edit]


Advice: use a professional programmer's editor, they are loaded with features useful to programmers:
- proper indentation, it helps seeing program structure, that helps spotting some errors.
- parenthesis matching, when cursor is on a parenthesis, the matching one gets highlighted. This feature would have helped to spot the error in your code.

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class PlayerControlelr : MonoBehaviour {

    public float moveSpeed;
    void Start () {
    }
    // Update is called once per frame
    void Update () {
        if(Input.GetAxisRaw("Horizontal") > 0.5f)
        (
        Transform.Translate (new Vector3(Input.GetAxisRaw("Horizontal") * moveSpeed * Time.deltaTime, 0f, 0f);<- right here is where the error comes up

        if(Input.GetAxisRaw("Vertical") > 0.5)
        {
        }
        {
        }
    }
}


Notepad++ Home[^]
UltraEdit | The Original Text Editor[^]

( // <-the opening parenthesis on this line is unmatched, and I would have expected a curled one.
Transform.Translate (new Vector3(Input.GetAxisRaw("Horizontal") * moveSpeed * Time.deltaTime, 0f, 0f);


这篇关于C#)预期错误?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆