BCE0044:期望EOF,找到“导入”

时间:2018-08-29 21:16:22

标签: javascript unity3d error-handling

我使用的是Unity的ScoreManager脚本的Javascript版本,当我最初将其导入到Unity项目中时,告诉我一个错误

  

错误BCE0018,名称“文本”不表示有效类型(“未找到”)。您是说'NUnit.Framework.Internal.Test'吗?

有人遇到了同样的问题,在答案中建议尝试添加import UnityEngine.UI;。我尝试了一下,它确实解决了BCE0018错误,但是现在出现了一个全新的错误,我不确定如何解决。新错误是

  

BCE0044期望EOF,已找到进口货。

我已经做过一些研究,其他人对}var也有类似的问题,但是我还没有看到有关导入的问题。有什么想法吗?这是我正在使用的完整脚本的副本。

pragma strict


static var score : int; // The player's score.

private var text : Text;       // Reference to the Text component.

import UnityEngine.UI;

function Awake ()
{
    // Set up the reference.
    text = GetComponent (Text);

    // Reset the score.
    score = 0;
}

function Update ()
{
    // Set the displayed text to be the word "Score" followed by the score value.
    text.text = "Score: " + score;
}

2 个答案:

答案 0 :(得分:1)

导入名称空间必须在文件的最上方,因此将>>> import re >>> s = "__x_a" >>> new_s = re.sub(r'^_*', lambda x: x.group().replace('_', '\_'), s) >>> print(new_s) \_\_x_a 移到compile example.cs --output example.exe translate example.exe --output example.ll之后

答案 1 :(得分:1)

您的代码中有两个问题:

1 import {Table, Column, Model, DataType} from 'sequelize-typescript'; @Table({ timestamps: false, freezeTableName: true, schema: 'TEST', tableName: 'Person' }) export class Person extends Model<Person> { @Column({ type: DataType.STRING, primaryKey: true }) ID: string; @Column(DataType.STRING) NAME: string; @Column({type:DataType.DATEONLY, get(){ let value : Date = this.getDataValue('START_DATE'); return value.getDay(); }}) START_DATE: Date; @Column({type:DataType.DATEONLY, get(){ let value : Date = this.getDataValue('END_DATE'); return value.getDay(); }}) END_DATE: Date; @Column({type:DataType.DATEONLY, get(){ let value : Date = this.getDataValue('MEET_START_DATE'); return value.getDay(); }}) MEET_START_DATE: Date; @Column({type:DataType.DATEONLY, get(){ let value : Date = this.getDataValue('MEET_END_DATE'); return value.getDay(); }}) MEET_END_DATE: Date; getDay(field,instance) { let value : Date = instance.getDataValue(field); return value.getDay(); } } 应该是pragma strict。注意前面的“#”。

2 。正如Hellium在回答中所说,#pragma strict放在错误的位置。应该将其放置在import UnityEngine.UI;之后,并在其余代码之前。

请注意,您应该停止使用Javascript / Unityscript。它已在Unity中终止,并且编译器也将很快被删除。您现在应该正在使用C#。

这是您的新代码:

#pragma strict
相关问题