I was wondering if there is a known bug with Mono and how it detects brackets
I keep getting this error.
c:\Users\Lapgar\Documents\New Unity Project\Assets\HomeMadeAssets\scripts\DoorManagerA.cs(4,4): Error CS1513: } expected (CS1513) (Assembly-CSharp)
Here is the code it claims is wrong.
using UnityEngine;
using System.Collections;
public class DoorManagerA : MonoBehaviour {
public Door door1;
public Door door2;
public bool hadLoadedLevelA;
public bool hadLoadedLevelB;
public GameObject spawnObject;
//public GameObject OldObject;
void OnTriggerEnter(){
//int whichDoor = 0;
if (door1!=null)
{
door1.OpenDoor();
//Debug.Log("\n" + this.transform.position.x + " " + this.transform.position.y + " " + this.transform.position.z + " ");
//whichDoor = 1;
}
if (door2!=null)
{
door2.OpenDoor();
//whichDoor = 2;
}
if(!hadLoadedLevelA)
{
CreatePrefab(1);
hadLoadedLevelA = true;
}
if(!hadLoadedLevelB)
{
CreatePrefab(2);
hadLoadedLevelB = true;
}
}
void CreatePrefab(int loadType)
{
//LoadType 1 = hadLevelLoadedLevel A which means door 1 which means longdoor1 opened
//LoadType 2 = hadLevelLoadedLevel B which means door 2 which means longdoor1 opened
Vector3 nextRoom = this.transform.position;
if(loadType == 2)
{
//Where it will appear next
nextRoom.y = nextRoom.y;
nextRoom.z = nextRoom.z + 5.59369f;
nextRoom.x = nextRoom.x - 12f;
}
//nextRoom.x = nextRoom.x + 1.3f;
//nextRoom.z = nextRoom.z + -5.59369f;
//nextRoom.x = nextRoom.x - 13.25f;
//nextRoom.x = nextRoom.x - 13.25f; space of the rooms not the door manager object, which is what this.transform.position is
//The original transformer, not the current one. Each means no clones of clones of clones
//Debug.Log ("\n" );
GameObject clone = Instantiate(spawnObject.transform, nextRoom, spawnObject.transform.rotation) as GameObject;
}
}
and here is what I did to “fix it”.
…
…
…
using UnityEngine;
using System.Collections;
public class DoorManagerA : MonoBehaviour {
public Door door1;
public Door door2;
public bool hadLoadedLevelA;
public bool hadLoadedLevelB;
public GameObject spawnObject;
//public GameObject OldObject;
void OnTriggerEnter(){
//int whichDoor = 0;
if (door1!=null)
{
door1.OpenDoor();
//Debug.Log("\n" + this.transform.position.x + " " + this.transform.position.y + " " + this.transform.position.z + " ");
//whichDoor = 1;
}
if (door2!=null)
{
door2.OpenDoor();
//whichDoor = 2;
}
if(!hadLoadedLevelA)
{
CreatePrefab(1);
hadLoadedLevelA = true;
}
if(!hadLoadedLevelB)
{
CreatePrefab(2);
hadLoadedLevelB = true;
}
}
void CreatePrefab(int loadType) {
//LoadType 1 = hadLevelLoadedLevel A which means door 1 which means longdoor1 opened
//LoadType 2 = hadLevelLoadedLevel B which means door 2 which means longdoor1 opened
Vector3 nextRoom = this.transform.position;
//Where it will appear next
nextRoom.y = nextRoom.y;
nextRoom.z = nextRoom.z + 5.59369f;
nextRoom.x = nextRoom.x - 12f;
GameObject clone = Instantiate(spawnObject.transform, nextRoom, spawnObject.transform.rotation) as GameObject;}}
I did nothing but move the last two brackets up to the last line of code. Yet Unity was fine with this when I built it, but not fine with it before.
From what I can tell there is nothing wrong the first time, but mono just goes crazy unless I do the second version.
I should also note that I do not recall getting this error until I updated to the latest version of unity, 4.6.1f1.