C# GUILayout.Box GUIContent

How do you setup a GUILayout.Box with GUIContent? I’ve tried moving GUIContent around within GUILayout.Box’s parameters but I can’t get it to work.

    void OnGUI() {
        //The Following below I have tried and do not work
        //GUILayout.Box("SomeBox",new GUIContent("It is just a box"));
        //GUILayout.Box("SomeBox"),new GUIContent("It is just a box");

    }
}

Like @Loius pointed out, though I would recommend caching this somewhere to avoid allocation for every frame of your game! GUIContent is a class not a struct!

Constant non-changing content:

private static GUIContent SomeBox = new GUIContent("SomeBox", "It is just a box");

void OnGUI() {
    GUILayout.Box(SomeBox);
}

Variable content:

private GUIContent someBoxContent = new GUIContent("SomeBox", "It is just a box");

void OnGUI() {
    GUILayout.Box(SomeBox);

    if (GUILayout.Button("Change content!")) {
        someBoxContent.text = "SomeSpecialBox";
        someBoxContent.tooltip = "Okay, this is not just a box!";
    }
}

I’m not exactly sure how you want it to be but this is what I know.

//Place X and Y are put down so you can place the text wherever you want
//sizeX and sizeY are so you can make the text whatever size you want
//You can change the size and place in the editor instead of in the script

public float placeX;
public float placeY;
public float sizeX;
public float sizeY;


void OnGUI()
{
  GUI.Box(new Rect(placeX, placeY, sizeX, sizeY), "Say something");
}

Hope this helps Vote yes if this is correct.