我正在使用来自Unity脚本参考的脚本: http://docs.unity3d.com/ScriptReference/CharacterController.Move.html
using UnityEngine;
using System.Collections;
public class ExampleClass : MonoBehaviour {
public float speed = 6.0F;
public float jumpSpeed = 8.0F;
public float gravity = 20.0F;
private Vector3 moveDirection = Vector3.zero;
void Update() {
CharacterController controller = GetComponent<CharacterController>();
if (controller.isGrounded) {
moveDirection = new Vector3(Input.GetAxis("Horizontal"), 0, Input.GetAxis("Vertical"));
moveDirection = transform.TransformDirection(moveDirection);
moveDirection *= speed;
if (Input.GetButton("Jump"))
moveDirection.y = jumpSpeed;
}
moveDirection.y -= gravity * Time.deltaTime;
controller.Move(moveDirection * Time.deltaTime);
}
}
但问题在于,当我构建它时,它会显示以下错误
有没有解决方案?
答案 0 :(得分:1)
我看到的唯一解决方案是使用Visual Studio 2015,因为MonoDevelop在上一代Unity版本中运行得非常糟糕。但是JavaScripts不起作用。顺便说一句,VS2015社区可以从Unity 5.3开始从Unity安装程序安装。
答案 1 :(得分:0)
如果您在Unity中添加新的/移动脚本,有时会发生这种情况(也可能使用Visual Studio)。
我到目前为止找到的唯一解决方案是关闭Unity和编辑器,转到硬盘上的文件夹并删除* .csproj和evtl。 * .sln文件。
(在最坏的情况下,您也可以尝试删除它也由Unity构建的Library文件夹)
然后重新使用Unity和编辑。现在它应该重建项目并正确解析。