Unityscript 动画参数 UCE0001: ';'预期的
Unityscript Animation Parameter UCE0001: ';' expected
好吧,我正在学习如何在 Unity 中使用动画参数(我来自 Flash AS3 背景)。正如您在下面看到的,我的目标是让 GameObject
的动画状态为 jump
。我将创建的动画参数 Boo
设置为 false,我的目的是在 Unityscript 代码中将其更改为 true。 GameObject
的动画控制器的名称只是 controller
。
但是控制台告诉我他们需要一个分号!如您所见,我的脚本中不缺少分号。这里有什么问题?如果您发现任何其他信息可能有助于解决此问题,我很乐意 post。
在第 3 行和第 4 行,您试图以 C#
样式而不是 Javascript
样式导入库。
因此,您应该使用 import
:
而不是 using
import UnityEngine;
import System.Collections;
... etc.
错误就会消失。但是会出现警告))为什么?
By default using UnityEngine(c#) or import UnityEngine(unityscript)
and System.Collection.Generic are automatically added to the top of
the script but you don't see it.
所以你可以删除这个导入,或者它给你:BCW0008: WARNING: Duplicate namespace: 'UnityEngine'
和 BCW0008: WARNING: Duplicate namespace: 'System.Collections'
。
另外 Unity3d
没有 Controller
组件。但它有 Animator
分量 http://docs.unity3d.com/ScriptReference/Animator.html
在您的情况下,最少的代码将是:
function Start () {
GetComponent(Animator).SetBool("Boo", true); //(GetComponent("Animator") as Animator).SetBool("Boo", true);
}
但是对于这个组件的全局使用,你应该声明变量 animator,类型为 Animator
。然后你可以在文件中的任何地方使用它。
示例(javascript tstyle):
#pragma strict
var anim : Animator;
function Start() {
anim = GetComponent(Animator); // GetComponent("Animator");
}
function Update() {
if (Input.GetKeyDown(KeyCode.Space))
anim.SetBool("Boo", true);
}
更多示例点击this link
好吧,我正在学习如何在 Unity 中使用动画参数(我来自 Flash AS3 背景)。正如您在下面看到的,我的目标是让 GameObject
的动画状态为 jump
。我将创建的动画参数 Boo
设置为 false,我的目的是在 Unityscript 代码中将其更改为 true。 GameObject
的动画控制器的名称只是 controller
。
但是控制台告诉我他们需要一个分号!如您所见,我的脚本中不缺少分号。这里有什么问题?如果您发现任何其他信息可能有助于解决此问题,我很乐意 post。
在第 3 行和第 4 行,您试图以 C#
样式而不是 Javascript
样式导入库。
因此,您应该使用 import
:
using
import UnityEngine;
import System.Collections;
... etc.
错误就会消失。但是会出现警告))为什么?
By default using UnityEngine(c#) or import UnityEngine(unityscript) and System.Collection.Generic are automatically added to the top of the script but you don't see it.
所以你可以删除这个导入,或者它给你:BCW0008: WARNING: Duplicate namespace: 'UnityEngine'
和 BCW0008: WARNING: Duplicate namespace: 'System.Collections'
。
另外 Unity3d
没有 Controller
组件。但它有 Animator
分量 http://docs.unity3d.com/ScriptReference/Animator.html
在您的情况下,最少的代码将是:
function Start () {
GetComponent(Animator).SetBool("Boo", true); //(GetComponent("Animator") as Animator).SetBool("Boo", true);
}
但是对于这个组件的全局使用,你应该声明变量 animator,类型为 Animator
。然后你可以在文件中的任何地方使用它。
示例(javascript tstyle):
#pragma strict
var anim : Animator;
function Start() {
anim = GetComponent(Animator); // GetComponent("Animator");
}
function Update() {
if (Input.GetKeyDown(KeyCode.Space))
anim.SetBool("Boo", true);
}
更多示例点击this link