Example #1
0
    void DrawCustomData()
    {
        bool needsSave = false;

        DrawLabel("2D Custom List");

        NewLine();
        Indent();

        if (DrawButton(SetDataSceneStrings.AddNewList))
        {
            twoDListData.custom_2dlist.Add(new List <GDESetCustomData>());
        }

        indexToRemove = DrawInt(indexToRemove);
        if (DrawButton(SetDataSceneStrings.RemoveList))
        {
            twoDListData.custom_2dlist.RemoveAt(indexToRemove);
            twoDListData.Set_custom_2dlist();
        }

        if (DrawButton(SetDataSceneStrings.Reset))
        {
            twoDListData.Reset_custom_2dlist();
        }

        NewLine(2);
        Indent();

        foreach (var subList in twoDListData.custom_2dlist)
        {
            if (DrawButton(SetDataSceneStrings.AddNewCustom))
            {
                GDESetCustomData newCustom = new GDESetCustomData(Random.value.ToString());
                newCustom.description = SetDataSceneStrings.KeyLbl + " \"" + newCustom.Key + "\"";

                subList.Add(newCustom);
                twoDListData.Set_custom_2dlist();
            }
            Indent();
            indexToRemove = DrawInt(indexToRemove);
            if (DrawButton(SetDataSceneStrings.RemoveIndexLbl))
            {
                subList.RemoveAt(indexToRemove);
                twoDListData.Set_custom_2dlist();
            }

            NewLine();
            Indent(2);

            for (int i = 0; i < subList.Count; i++)
            {
                if (i > 0)
                {
                    NewLine();
                    Indent(2);
                }

                DrawLabel(subList[i].Key + ":");

                string oldKey = subList[i].Key;
                newKey = DrawString(newKey);

                string oldVal = subList[i].description;
                subList[i].description = DrawString(subList[i].description);

                if (oldKey != newKey && DrawButton(SetDataSceneStrings.SetRefBtn))
                {
                    subList[i] = new GDESetCustomData(newKey);
                    needsSave  = true;
                }

                needsSave = (subList[i].description != oldVal) | needsSave;
            }

            NewLine(2);
            Indent();
        }

        if (needsSave)
        {
            twoDListData.Set_custom_2dlist();
        }
    }