我有书中的剧本(Sams在24小时内教你自己统一游戏开发)我无法编译它继续向我扔错误 我添加了所有缺少的汇编参考,但它仍然无法找到一些东西。 这是视觉工作室的装配 这是代码
using UnityEngine;
using System.Collections;
using UnityEngine.UI;
using UnityStandardAssets.Characters.FirstPerson;
public class GameControlScript : MonoBehaviour {
//The amount of ellapsed time
private float time = 0;
//Flags that control the state of the game
private bool isRunning = false;
private bool isFinished = false;
//place holders for the player and the spawn point
public Transform spawnPoint;
public GameObject player;
//place holders for the scripts on the character controller
public CharacterMotor motorScript;
public MouseLook lookScript;
//This resets to game back to the way it started
private void InitLevel()
{
time = 0;
isRunning = true;
isFinished = false;
//move the player to the spawn point
player.transform.position = spawnPoint.position;
//Allow the character controller to move and
//look around
motorScript.enabled = true;
lookScript.enabled = true;
}
// Use this for initialization
void Start () {
//prevent the character controller
//from looking around
motorScript.enabled = false;
lookScript.enabled = false;
}
// Update is called once per frame
void Update () {
//add time to the clock if the game
//is running
if(isRunning)
time += Time.deltaTime;
}
//This runs when the player enters the finish
//zone
public void FinishedGame()
{
isRunning = false;
isFinished = true;
//freeze the character controller
motorScript.enabled = false;
lookScript.enabled = false;
}
//This section creates the Graphical User Interface (GUI)
void OnGUI()
{
if(!isRunning)
{
string message;
if(isFinished)
message = "Click to Play Again";
else
message = "Click to Play";
if(GUI.Button(new Rect(Screen.width / 2 - 70, Screen.height/2, 140, 30), message))
{
//start the game if the user clicks to play
InitLevel ();
}
}
//If the player finished the game, show the final time
if(isFinished)
{
GUI.Box(new Rect(Screen.width / 2 - 65, 185, 130, 40), "Your Time Was");
GUI.Label(new Rect(Screen.width / 2 - 10, 200, 20, 30), ((int)time).ToString());
}
//If the game is running, show the current time
else if(isRunning)
{
GUI.Box(new Rect(Screen.width / 2 - 65, Screen.height - 115, 130, 40), "Your Time Is");
GUI.Label(new Rect(Screen.width / 2 - 10, Screen.height - 100, 20, 30), ((int)time).ToString());
}
}
}
我将参考添加到2个不同的组件中,然后抛出错误 我加 使用UnityEngine.UI; 使用UnityStandardAssets.Characters.FirstPerson;
但仍然收到错误 Assets / Scripts / GameControlScript.cs(20,9):错误CS0246:找不到类型或命名空间名称“CharacterMotor”。你错过了装配参考吗?