Ok, I am new to scripting, my question is, how could I go about making a simple (as simple as you can get) inventory. I just want one that works. Any help?
There’s not a function that just does inventory.
Check out GUILayout for automatic positioning or GUI for you-choose-everything positioning.
You need a logical Item class for sure.
Here’s an example of drawing a bunch of items in a grid pattern - you could substitute icons in for the “”+ix values and instantly look great.
#pragma strict
var items : int[];
function Start() {
items = new int[42];
}
private var scroll : Vector2;
function OnGUI() {
GUILayout.BeginArea( Rect(0,0,180,200) );
scroll = GUILayout.BeginScrollView( scroll );
GUILayout.BeginVertical();
for ( var ix : int = 0; ix < items.length; ) {
GUILayout.BeginHorizontal();
for ( var x : int = 0; x < 4 ix < items.length; x++ ) {
if ( GUILayout.Button( GUIContent(""+ix,"You're hovering over " + ix), GUILayout.Width(40) ) ) Debug.Log("You clicked " + ix);
ix++;
}
GUILayout.EndHorizontal();
}
GUILayout.EndVertical();
GUILayout.EndScrollView();
GUILayout.EndArea();
}
I will look into this as soon as i can. Thanks!