The tutorial page doesn’t exist, and I’m not sure what function in it I should use, and how I would use it if I did.
My current code is, essentially “Take List inventory[ ], foreach gameobject in inventory create new button with a tooltip that shows the item’s stats” But it doesn’t scale since it is not in GUILayout.
I would love an idea what I’d need to do for something similar with GUILayout. I was looking at the scrollbars or selection grid most likely.
Here is an example of how to use GUILayout and tooltips (you’ll need to assign your inventory text and tips in the inspector):
using UnityEngine;
using System.Collections;
public class NewBehaviourScript : MonoBehaviour {
public GUIContent[] inventory;
public Rect inventoryPosition = new Rect(10,10,170,300);
void OnGUI (){
GUILayout.BeginArea(inventoryPosition);
foreach (GUIContent item in inventory){
GUILayout.Button(item, GUILayout.Width(150), GUILayout.Height(75));
}
GUILayout.Label(GUI.tooltip);
GUILayout.EndArea();
}
}
Thanks, that’s a lot more helpful than the docs, although i already have an inventory system, which I was fetching from. But, if there’s a way I can do GUILayout.Label(GUI.tooltip) I THINK I know how I can do it.
I don’t really understand pretty much any of the docs on the GUILayout stuff, all of the overloaded methods are just like, wall of text to me.
Edit: I tried it like you said, and there was one problem, the label doesn’t seem to appear, when I had forgotten the label and just included the tooltips inside as the main string, it worked fine, but in a GUILayout.Label (GUI.tooltip); I can’t get them working