I do not understand this error

hello,
I have a small problem with a script and I do not know where it came from …

My error :

alt text

and my code :

using UnityEngine;
using System.Collections;

public class UIBox : ScriptableObject {

	public float xSize;
	public float ySize;

	public string title;
	public float titleSize;
	public Color titleColor;
	public string titleStyle;

	public Color backgroundBoxColor;
	public Texture2D backgroundBoxTexture;

	public UIElements[] elements = new UIElements[0];

	public bool display;
	
	public void displayBox(float xSize, float ySize, string title, float titleSize,
	              string titleStyle, Color titleColor, Color backgroundBoxColor, 
	              Texture2D backgroundBoxTexture, UIElements[] elements, bool display) {
		
		elements = new UIElements[0];

		string richTextBefore = "";
		string richTextAfter = "";

		string titleColorBefore = "<color=" + titleColor.ToString + ">";
		string titleColorAfter = "</color>";

		string titleSizeBefore = "<size="+ titleSize +">";
		string titleSizeAfter = "</size>";

		GUIStyle boxStyle;
		boxStyle.

		if(titleStyle == "bold") {
			richTextBefore = "<b>";
			richTextAfter = "</b>";
		} else if(titleStyle == "italic") {
			richTextBefore = "<i>";
			richTextAfter = "</i>";
		}

		title = titleSizeBefore + titleColorBefore + richTextBefore + title + richTextAfter + 
			titleColorAfter + titleSizeAfter;

		if(display == true && xSize >= 0 && ySize >= 0 && titleColor != null && backgroundBoxColor != null) {
			GUI.Box (new Rect ((Screen.width / 2) - (xSize / 2), (Screen.height / 2) - (ySize / 2), 
			                   xSize, ySize), title);

			GUI.BeginScrollView (new Rect ((Screen.width / 2) - (xSize / 2), (Screen.height / 2) - (ySize / 2), 
			                         xSize, ySize));
			GUI.EndScrollView ();
		}
	}
}

thank you !!!

Let’s take the first error message:
“…/UIBox.cs(39,18): error … unexpected symbol if …”
The first part “…/UIBox.cs” is your script, which you obviously already knew.
The next part “(39,18)” is the position of the error: Line 39, Column 18.
The last part is the error number and the message.

If the message isn’t clear then you have to look at the position of the error.
If you think this line:

if(titleStyle == "bold") {

is correct, then you have to look at the code above this line. Most of the time this means you made a typo somewhere and the compiler doesn’t understand what you tried to do there. That’s why the error message isn’t really helpful here except that it tells you a starting point where you have to look for your typo.
If you scan your code from line 39 upwards you’ll find:

boxStyle.

Which obviously is not a valid statement. So you’ll have to fix this and look if this fixes the other error messages. If other messages remain then you’ll have to do this for each message.

Thank you! I noticed the error and I forgot to close the post, next time I would focus more on the little details before posting useless things, and therefore waste more time than anything else. Thank you again :slight_smile: