Ok, I have been following tutorial on leveling system, and I have some errors. Error line 22: Unexpected Symbol '}'. Line 34: Parsing Error. Here is script: using UnityEngine; using System.Collections; public class PlayerLevelSystem : MonoBehaviour { private int curLevel = 1; private int maxLevel; private int curExp = 0; private int maxExp = 100; // Use this for initialization void Start () { } // Update is called once per frame void Update () { if(curExp >= maxExp) } curExp=100; curLevel++; } void OnGUI() { GUILayout.BeginArea(new Rect(20,50,40,20), curexp + "/" + maxExp); GUILayout.BeginArea(new Rect(20,50,40,20), "Level:" + curLevel); }
Looks like where you have Code (csharp): // Update is called once per frame void Update () { if(curExp >= maxExp) } curExp=100; curLevel++; it should be Code (csharp): if(curExp >= maxExp) { curExp=100; curLevel++; } instead you also need to remove the } on line 26, and place it at the end of the script, your cutting out Code (csharp): void OnGUI() { GUILayout.BeginArea(new Rect(20,50,40,20), curexp + "/" + maxExp); GUILayout.BeginArea(new Rect(20,50,40,20), "Level:" + curLevel); } where you currently have it placed. so this should work Code (csharp): using UnityEngine; using System.Collections; public class PlayerLevelSystem : MonoBehaviour { private int curLevel = 1; private int maxLevel; private int curExp = 0; private int maxExp = 100; // Use this for initialization void Start () { } // Update is called once per frame void Update () { if(curExp >= maxExp) { curExp=100; curLevel++; } } void OnGUI() { GUILayout.BeginArea(new Rect(20,50,40,20), curexp + "/" + maxExp); GUILayout.BeginArea(new Rect(20,50,40,20), "Level:" + curLevel); } }
Ok, the script worked, but it seems to be throwing at me no GUI. The EXP text shows, but no GUI, and level isn't even there. could you show me what I am doing wrong?
So would I do a GUI.box? or what? Because someone said to use GUILayout.BeginArea. And yes, I cant see the level.
You can have some fun with the GUI in unity, you should check out the reference page here: GUI Scripting Guide