Question by
Betaaubrey1 · Dec 13, 2015 at 07:41 PM ·
error messagevoid
key word void cannot be used in this context
using UnityEngine; using System.Collections;
public class PlayerIO : MonoBehaviour {
RaycastHit hit;
int MaxBuildDist = 10;
public Transform RetAdd;
public Transform RetDelete;
Color Block_Color = Color.blue;
bool Block_Menu = false;
// Use this for initialization
void Start (){
RetAdd = GameObject.Find("RetAdd").transform;
RetDelete = GameObject.Find("RetDelete").transform;
}
// Update is called once per frame
void Update (){
if (Input.GetKeyDown(KeyCode.E))
Block_Menu = !Block_Menu;
if (Block_Menu)
Time.timeScale = 0;
if
(!Block_Menu){
if(Physics.Raycast(Camera.main.ScreenPointToRay(new Vector3((Screen.width / 2), (Screen.height / 2), 0)), out hit, MaxBuildDist)){
RetAdd.GetComponent<Renderer>().enabled = true;
if(hit.transform.tag == "Block"){
RetAdd.transform.position = hit.transform.position + hit.normal;
RetDelete.transform.position = hit.transform.position;
RetDelete.GetComponent<Renderer>().enabled = true;
}
if(hit.transform.tag != "Block"){
RetDelete.GetComponent<Renderer>().enabled = false;
RetAdd.transform.position = new Vector3(hit.point.x, hit.point.y + 0.5f, hit.point.z);
}
if(Input.GetMouseButtonDown(0)){
GameObject block = (GameObject)Instantiate(Resources.Load("Block01"), RetAdd.transform.position, Quaternion.identity);
block.GetComponent<Renderer>().material.color = Block_Color;
}
else if(Input.GetMouseButtonDown(1) && hit.transform.tag != "Floor"){
Destroy(hit.transform.gameObject);
}
else{
RetAdd.GetComponent<Renderer>().enabled = false;
RetDelete.GetComponent<Renderer>().enabled = false;
}
} } void OnGUI(){ if(Block_Menu) Block_Menu_GUI(); }
void Block_Menu_GUI(){
GUILayout.BeginVertical();
if(GUILayout.Button("Green"))
Block_Color = Color.green;
if(GUILayout.Button("Red"))
Block_Color = Color.red
if(GUILayout.Button("Blue"))
Block_Color = Color.blue
GUILayout.EndVertical();
} }
Comment
very hard to tell with the bad code formatting, but from what I can see, it looks as though you may need another } before void OnGUI()
Your answer
![](https://koobas.hobune.stream/wayback/20220612052459im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Void error 1 Answer
Unexpected symbol `void' 1 Answer
I need someone to help me: error CS1525: Unexpected symbol `void' 0 Answers
unexpected void error 1 Answer
Normalize(); help 0 Answers