C# Array, GuiText, assign strings.

Hi,

Im getting an array from a PHP script from my server with 11 strings.

I have an array with 11 gameobject(with GUIText on them) and i want to assign the strings to the gameobjects.

So that the Guitext show the string info.

like Array_GameObjects = Array_php*;*
C#
Kind Regards

[Here][1] is the doc about GUIText.

if Array_GameObjects contains GUIText game objects, you need to access their text to change it. Try something like that :

GUIText myCurrText = Array_GameObjects*;*

myCurrText.text = Array_php*;
_
[1]: http://docs.unity3d.com/Documentation/Components/class-GuiText.html*_

I changed the code to this, and it works :slight_smile:

IEnumerator GetData(WWW w)
    {
        if(Loading == true)
        {
            guiLoading.guiText.text = "Loading Data";
        }
        else if (Loading == false)
        {
            guiLoading.guiText.text = "";
        }        

        

        if (w.error != null)
        {
            print("There was an error getting the high score: " + w.error);
        }

        else
        {
            Loading = false;
            

            RegexOptions options = RegexOptions.None;
            Regex regex = new Regex(@"((""((?<token>.*?)()"")|(?<token>[^&&]+))(\s)*)", options);
            string input = w.text;
            var result = (from Match m in regex.Matches(input)
                          where m.Groups["token"].Success
                          select m.Groups["token"].Value).ToList();
            int pos = 0;
            for (int i = 0; i < result.Count(); i += 2, pos++)
            {                                   
                GameObject currentGuiText = Instantiate(GuiPrefab, new Vector3(0,0,0), Quaternion.identity) as GameObject;
                
                _list.Add(currentGuiText);

                result[pos] = result*;*

}
result.RemoveRange(pos, result.Count - pos);
Debug.Log(“result” +result.Count);
Debug.Log(“list” + _list.Count);
for (int i = 0; i < result.Count(); i++)
{
list.guiText.text = string.Format(“{1}”, i, result*);*_

Loading = false;

}

}