Xeong Question PT 2 : Search Bar Issue

Ok i made te Search Bar with a help from a guy named Scribe. But now i’m having issues with this… When ever I search my items in the search bar, they just appear stacking on one another like a combined bunch of Potatoes. I can’t read anything like that.

So i had this idea. I tried making the rect of the position change for each item visably searched in the searcher, but i cant get anything to work… If only someone made a proper Tutorial on how to make a search bar : ( I type in Search Bar Tutorial on Youtube and all i get is Healthbar tutorials lol.

Well anyways. Here is my Working Code For the Search Bar.

var searchText = "";
var items : GameObject[];
function OnGUI()
{
   GUILayout.BeginHorizontal(EditorStyles.toolbar);
   GUILayout.FlexibleSpace();
   searchText = GUILayout.TextField(searchText, EditorStyles.toolbarTextField);
   GUILayout.EndHorizontal();
   searchText = GUI.TextField (Rect (25, 25, 100, 30),searchText);
   
   
   
   
      // Do comparison here. For example
            for (var i = 0; i < items.Length; i++)
   {
         if (items*.name.Contains(searchText)){*

{
GUI.Label(Rect (50, 50, 210, 80),(items*.name));*
}
}
}
}
And here is how my problem looks like… At the Bottom Left
http://i56.servimg.com/u/f56/13/98/73/49/a_prob11.png
Once again i’d really appreciate it if you can help.

Hello again Xeong.

So basically you want to make the ‘y’ value in your Label larger every time an object is found. The best way I know is to set up a new variable and then increment it every time your if statement returns true, then use that value to multiply the y value in your label.

Here’s some sample code:

function OnGUI() {
	searchString = GUI.TextField (Rect (10, 10, 100, 30),searchString);
	
	var a = 0;
	for (var i = 0; i < items.length; i++) {
		if ((items*.name).Contains(searchString));{*

_ GUI.Label(Rect (10, (a+1)50, 210, 80), items.name);_
_
a++;_
_
}_
_
}_
_
}*_
Hope that works for you!
Scribe