click is not working on my button, what am i doing wrong ??

Debug.Log ("hey! you clicked on: " + customerSearchResult );
This line is working perfectly fine in this code-
```

  •   void OnGUI()
    

{
if(length!=null){
// GUILayout.BeginScrollView();

		scrollViewVector = GUILayout.BeginScrollView(scrollViewVector, GUILayout.Width(100), GUILayout.Height(100));
        //GUILayout.Label(innerText);
		for (int i=customerSearchResult.Length-1; i>=0; i--){
                    if (GUILayout.Button(customerSearchResult[i], "label") ) {
                    Debug.Log ("hey! you clicked on: " + customerSearchResult[i] );
            }
            }
    GUILayout.EndScrollView();
	}

}*
* *whereas the same line is not working from the code below -* *

  • void OnGUI()
    {
    if(length>0){
    int forGuiArrangement = 1;
    scrollViewVector = GUI.BeginScrollView (new Rect (260, 50, 100, 100), scrollViewVector, new Rect (0, 0, 400, 400));
    for (int i=customerSearchResult.Length-1; i>=0; i–){
    forGuiArrangement = forGuiArrangement+1;
    if (GUI.Button(new Rect(20, 10forGuiArrangement, 150, 100), customerSearchResult[i], “label”)) {
    Debug.Log ("hey! you clicked on: " + customerSearchResult[i] );
    }
    }
    GUI.EndScrollView();
    }
    }

    ```
    What is wrong that i am doing ??

In this case you should use GUILayout for the button. That will make the code work and you don’t have to think about the button positioning.

but how to position its x and y ?? cn you guide me on it

You’ve set the height for each of the buttons to 100 but you only increment the Y value by 10 each time so the buttons overlap. Try setting the height to 20 and increment by 20.

Also try moving forGuiArrangement = forGuiArrangement + 1; so it comes after your GUI.Button call, that will remove the empty space at the top.