Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialPeter Javorkai
31,477 PointsRunning this script with the debug I get an error message in line 18: unexpected symbol 'else' in class...
When I run the script with the debug I get the following error message: unexpected symbol 'else' in class, struct or interface member declaration primary constructor body is not allowed.
Are these OK?
Peter Javorkai
31,477 PointsThank you Seth! I'll check it later. :)
2 Answers
Peter Javorkai
31,477 PointsI've checked everywhere, what am I missing? This code still showing a compiler error.
using UnityEngine; using System.Collections; using UnityEngine.VR;
public class VRAdjustment : MonoBehaviour {
private Vector3 monitorRotation = new Vector3 (-12f, 0f, 0f);
private Vector3 openVRPosition = new Vector3 (0f, -.1.75f, 0f);
// Use this for initialization
void Awake () {
if (!VRDevice.isPresent) {
transform.localRotation = Quaternion.Euler(monitorRotation);
} else {
if (VRSettings.loadedDeviceName == "OpenVR") {
transform.localPosition = openVRPosition;
}
}
}
// Update is called once per frame
void Update () {
if (Input.GetKeyUp (Keycode.R)) {
InputTracking.Recenter ();
}
}
void OnApplicationQuit () {
VRSettings.enabled = false;
}
}
Ulan Assanoff
9,922 PointsThere is an error in this line if (Input.GetKeyUp (Keycode.R)) , it should be KeyCode.R with capital C
Peter Javorkai
31,477 PointsThank you Ulan, I'm going to check!
Seth Kroger
56,414 PointsSeth Kroger
56,414 PointsSounds like you have a mismatched curly brace error one of your C# scripts causing it not to compile. Let's take a look at the code you wrote.