Text not displaying with custom GUIStyle

Hi all,
I tried to make something like an event log which, lists nicely the thrown events together with an icon.

So I defined a GUIStyle in my script and changed the values accordingly in the Inspector.

That’s what I ended up with:

var InfoIcon : Texture2D;
private var EventMessages : ArrayList;
var ConsoleGUIStyle : GUIStyle;

function Start() {
	EventMessages = new ArrayList();
}

function OnGUI() {
	if (GUI.RepeatButton(rel(0.18,0.76,0.02,0.02),"+")) {
		GameObject.Find("Bert450_Boot").GetComponent("Boat").SendMessage("zoomMap",5);
	}
	if (GUI.RepeatButton(rel(0.197,0.777,0.02,0.02),"-")) {
		GameObject.Find("Bert450_Boot").GetComponent("Boat").SendMessage("zoomMap",-5);
	}
	Console();
}

function rel(x : float, y: float, w: float, h: float) : Rect {
	return Rect(Screen.width*x, Screen.height*y, Screen.width*w, Screen.height*h);
}

function LogMessage(message: String) {
	EventMessages.Add(message);
	if (EventMessages.Count > 10) {
		EventMessages.RemoveAt(EventMessages.Count - 1);
	}
}

function Console() {
	GUILayout.BeginArea(rel(0.05,0.4,0.2,0.2));
	GUILayout.Label("");
		GUILayout.BeginVertical();
	if (EventMessages.Count > 0) {
		for (var Message : String in EventMessages) {
			GUILayout.Label(GUIContent(InfoIcon,Message),ConsoleGUIStyle);
		}
	}
		GUILayout.EndVertical();
	GUILayout.EndArea();
}

So I try, unless the Messages are empty, to create a custom label with an icon and some info text, but the text is not displayed. I think I sticked to the scripting manual and tried a few things but nothing worked.
Can anyone help me please?
Thank you in advance!
Regards

I’ve done the same thing except I don’t use icons, but you could easily add them by modifying the MyDebugItem struct. (Example is C#)

In your "global’ class, create a struct(which defines each debug list item) and an ArrayList (our Debug Log) - we overload the method to allow for a title item or title+details items:

//My Debug Log Struct
    public struct MyDebugItem
    {
        public bool ShowDetails;
        public string TimeStamp;
        public string ItemHeader;
        public string ItemDetails;
        public MyDebugItem(string mItemHeader, string mItemDetails)
        {
            this.ShowDetails = false;
            this.TimeStamp = DateTime.Now.ToString("dd-MMM-yyyy HH:mm:ss");
            this.ItemHeader = mItemHeader;
            this.ItemDetails = mItemDetails;
        }
        public MyDebugItem(string mItemHeader)
        {
            this.ShowDetails = false;
            this.TimeStamp = DateTime.Now.ToString("dd-MMM-yyyy HH:mm:ss");
            this.ItemHeader = mItemHeader;
            this.ItemDetails = "No Additional Information";
        }
    }
    public static ArrayList MyDebugLog = new ArrayList();

To add stuff to the debug log, you have two options (with details or just the title):

        MyGlobalScript.MyDebugLog.Add(new MyGlobalScript.MyDebugItem("App Initialized Successfullly"));
        MyGlobalScript.MyDebugLog.Add(new MyGlobalScript.MyDebugItem("Data Path", Application.dataPath));

This is the GUI used to display the debug log - mine is also setup for a custom GUISKin so it will probably look strange using the default. However, it does show a nice way to create a collapsable debug log.

using UnityEngine;
using System.Collections;
using System;

public class DebugWindow : MonoBehaviour
{
    private Rect DebugWindowPosition;
    private Vector2 DebugWindowLogScrollPos;
    private bool FocusDebugWindow = false;
    void OnGUI()
    {

        DebugWindowPosition = GUI.Window(1, DebugWindowPosition, DoDebugLogWindow, "My Debug Log");
    }

    void DoDebugLogWindow(int mWindowID)
    {
        if (FocusDebugWindow)
        {
            GUI.BringWindowToFront(mWindowID);
            GUI.FocusWindow(mWindowID);
            FocusDebugWindow = false;
        }
        if (GUI.Button(new Rect(284, 10, 16, 16), "", GUI.skin.GetStyle("closebutton16x16"))) ShowDebugWindow = false;
        GUILayout.BeginVertical();
        GUILayout.Space(25);
        DebugWindowLogScrollPos = GUILayout.BeginScrollView(DebugWindowLogScrollPos);
        for (int i = 0; i < MyGlobalScript.MyDebugLog.Count; i++)
        {
            MyGlobalScript.MyDebugItem thisDI = new MyGlobalScript.MyDebugItem();
            thisDI = (MyGlobalScript.MyDebugItem)MyGlobalScript.MyDebugLog[i];
            if (!thisDI.ShowDetails)
            {
                GUILayout.BeginVertical();
                GUILayout.BeginHorizontal();
                thisDI.ShowDetails = GUILayout.Toggle(thisDI.ShowDetails, "", GUILayout.Width(28), GUILayout.Height(28));
                MyGlobalScript.MyDebugLog[i] = thisDI;
                string DebugSummaryItem = thisDI.ItemHeader + ": " + thisDI.ItemDetails;
                if (DebugSummaryItem.Length > 32) DebugSummaryItem = DebugSummaryItem.Substring(0, 29) + "...";
                GUILayout.Label(DebugSummaryItem, GUILayout.Height(28));
                GUILayout.EndHorizontal();
            }
            else
            {
                GUILayout.BeginVertical();
                GUILayout.BeginHorizontal();
                thisDI.ShowDetails = GUILayout.Toggle(thisDI.ShowDetails, "", GUILayout.Width(32), GUILayout.Height(28));
                MyGlobalScript.MyDebugLog[i] = thisDI;
                GUILayout.TextArea(thisDI.TimeStamp + "\n" + thisDI.ItemHeader + "\n" + thisDI.ItemDetails, GUILayout.Width(220));
                GUILayout.EndHorizontal();
            }
            GUILayout.EndVertical();
        }
        GUILayout.EndScrollView();
        GUILayout.EndVertical();
        GUI.DragWindow();
    }
}