Android Java统一错误

Android Java统一错误,android,unity3d,Android,Unity3d,我是java新手,正在尝试运行一些示例代码。我得到以下错误 上面写着“;”预期,插入;在每个变量的末尾插入分号 我想知道如何解决这个问题,让代码运行,谢谢 #pragma strict import UnityEngine; import System.Collections; public class Move { //A method that Unity uses to re-run the code every second function Update ()

我是java新手,正在尝试运行一些示例代码。我得到以下错误

上面写着“;”预期,插入;在每个变量的末尾插入分号

我想知道如何解决这个问题,让代码运行,谢谢

#pragma strict
import UnityEngine;
import System.Collections;

public class Move 
{

    //A method that Unity uses to re-run the code every second
    function Update ()
    {
        double moveTime;
        double currentMoveTime;
        double perc = 1;
        //if the input is given from an android
        if ((Input.GetButtonDown("left") || Input.GetButtonDown("right") || Input.GetButtonDown("center")))
        {
            if (perc == 1)
            {
                moveTime = 1;
                currentMoveTime = 0;
            }
        }
        //Adjusting position
        startPos = gameObject.transform.position;
        if(((Input.GetButtonDown("right") && gameObject.transform.position == endPos)))
        {
            endPos = new Vector3(transform.position.x + 1, transform.position.y, transform.position.x);
        }
        if((Input.GetButtonDown("left") && gameObject.transform.position == endPos))
        {
            endPos = new Vector3(transform.position.x - 1,  transform.position.y, transform.position.x);
        }
        if((Input.GetButtonDown("center") && gameObject.transform.position == endPos))
        {
            endPos = new Vector3(transform.position.x,  transform.position.y, transform.position.x);
        }
        //Speed up move time after enough time passes
        currentMoveTime += Time.deltaTime * 5.5;
        perc = currentMoveTime / moveTime;
        gameObject.transform.position = Vector3.Lerp(startPos, endPos, perc);
    }
}
您不能在Unity中使用Java。 你看到的是C# 我看到了第一行:
#pragma strict
这是什么?这在你的代码中吗?另外,这不是java代码:
function Update()
java没有关键字
function
您正在混合C#和Unityscript/Javascript。请用一个。我建议你学C。你可以开始不,这不是C#,它(主要)是UnityScript/Javascript。 You can't use Java in Unity. What you see is C#