将C#学习为Unity脚本。以下内容无法编译。通过将代码放入" void update"我已经解决了这个问题。但我显然遗漏了一些东西。我在编译器失败的地方发表评论。
任何启蒙都会非常感激!
using UnityEngine;
using System.Collections;
public class ThrottleControl : MonoBehaviour {
public float
ThrottlePosition,
ThrottleEffectiveness,
ThrottleReturnSpeed;
private string ThrottleStr = "Throttle";
void GetThrottlePosition()
{
if (Input.GetButtonDown (ThrottleStr))
{
//code here eliminated for clarity
}
} // GetThrottle Position
// Use this for initialization
void Start () {
ThrottleEffectiveness = 0.1f;
}
// Update is called once per frame
void Update () { //compiler error here about allowed statements
GetThrottlePosition;
}
}
只有赋值,调用,递增,递减,等待和新对象表达式才能用作语句
答案 0 :(得分:5)
GetThrottlePosition
void Update ()
{
GetThrottlePosition();
}