0
我正在製作一款名爲UnityCraft的遊戲,我嘗試了一種切換塊的方法!
這裏是我的代碼:C#解析錯誤
using UnityEngine;
using System.Collections;
public class BuildScript : MonoBehaviour {
RaycastHit hit;
public int blockSelected = 1;
public Transform prefab;
// Use this for initialization
void Start() {
}
// Update is called once per frame
void Update() {
if(Input.GetButtonDown(1)){
blockSelected = 1;
}
if(Input.GetButtonDown(2)){
blockSelected = 2;
}
if(blockSelected == 1){
prefab = dirt;
}
if(blockSelected == 2){
prefab = brick;
}
Ray ray = camera.ViewportPointToRay (new Vector3 (0.5f, 0.5f, 0));
Vector3 G = new Vector3 (Mathf.Round (hit.point.x), Mathf.Ceil (hit.point.y), Mathf.Round (hit.point.z));
if (Physics.Raycast (ray, out hit)) {
if (Input.GetMouseButtonDown (0)) {
Destroy (hit.collider.gameObject);
print ("Block Destroyed!");
}
if (Input.GetMouseButtonDown (1)) {
Instantiate (prefab, G, Quaternion.identity);
}
}
}
}
我有一個預製稱爲磚和一個叫污垢,它們鏈接到塊。
它提出瞭解析錯誤 – jezza23
你的問題是什麼? – SLaks
錯誤在哪一行?什麼是錯誤信息? –