【发布时间】:2015-02-12 13:30:21
【问题描述】:
我需要从Unity 中的另一个脚本关闭一个脚本。该脚本位于C# 中,而我要关闭的脚本位于JS 中。两个脚本都附加到同一个对象。我收到的错误说没有启用这样的东西。有什么想法吗?以下是我的部分代码。
void Update ()
{
var walkScript = GameObject.FindWithTag ("Player").GetComponent ("CharacterMotor");
if ((Input.GetKey ("p")) && (stoppedMovement == true)) {
stoppedMovement = false;
walkScript.enabled = true;
} else if ((Input.GetKey ("p")) && (stoppedMovement == false)) {
stoppedMovement = true;
walkScript.enabled = false;
}
我收到的错误如下:
Assets/Standard Assets/Character Controllers/Sources/Scripts/MouseLook.cs(41,36): error CS1061: Type
UnityEngine.Component' does not contain a definition forenabled' 并且找不到扩展方法enabled' of typeUnityEngine.Component'(你是缺少 using 指令或程序集引用?)
【问题讨论】:
标签: c# unity3d unityscript gameobject unity-components