Сортировка элементов

Форум для самых маленьких, а так же тех, кому недосуг читать справку самостоятельно.

Re: Сортировка элементов

Сообщение alew 26 ноя 2020, 11:04

Может имеет смысл так делать:
Синтаксис:
Используется csharp
public List<int> buttonPress = new List<int>();
public Vector2 scrolPoss = Vector2.zero;
    public struct dataInfo
    {
       public GameObject go;
        public string name;
        public string kill;
        public string death;
        public string[] stringArray;
    }
    public List<dataInfo> spisok = new List<dataInfo>();

 void Start()
    {
        for (int i = 0; i < 10; i++)
        {
            dataInfo dataInfo = new dataInfo();
            dataInfo.go = new GameObject("gameObj" + i.ToString());
            dataInfo.name = "name_" + i.ToString();
            dataInfo.kill = "kill_" + i.ToString();
            dataInfo.death = "death_" + i.ToString();
            int r = Random.Range(0, 10);
            dataInfo.stringArray = new string[r];
            for (int j = 0; j < r; j++)
                        dataInfo.stringArray[j] = "string_array_" + i.ToString() + "_" + j.ToString();
            spisok.Add(dataInfo);
            buttonPress.Add(-1);
        }
}
private void OnGUI()
    {
        scrolPoss = GUILayout.BeginScrollView(scrolPoss,"window");
        for (int i = 0; i < spisok.Count; i++)
        {
            if (GUILayout.Button(spisok[i].go.name)) buttonPress[i] = buttonPress[i] * -1;
            if (buttonPress[i] ==1)
            {
                GUILayout.Label(spisok[i].name);
                GUILayout.Label(spisok[i].kill);
                GUILayout.Label(spisok[i].death);
                for (int j = 0; j < spisok[i].stringArray.Length; j++)
                           GUILayout.Label("         " + spisok[i].stringArray[j]);
            }
        }
        GUILayout.EndScrollView();
    }
 
alew
UNIт
 
Сообщения: 76
Зарегистрирован: 23 ноя 2018, 19:59

Пред.

Вернуться в Почемучка

Кто сейчас на конференции

Сейчас этот форум просматривают: нет зарегистрированных пользователей и гости: 26