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 trial

Game Development VR in Unity VR Setup VR Camera Setup

Peter Javorkai
Peter Javorkai
31,477 Points

Running 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?

Seth Kroger
Seth Kroger
56,413 Points

Sounds 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.

Peter Javorkai
Peter Javorkai
31,477 Points

Thank you Seth! I'll check it later. :)

2 Answers

Peter Javorkai
Peter Javorkai
31,477 Points

I'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
Ulan Assanoff
9,922 Points

There is an error in this line if (Input.GetKeyUp (Keycode.R)) , it should be KeyCode.R with capital C

Peter Javorkai
Peter Javorkai
31,477 Points

Thank you Ulan, I'm going to check!