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

        DrawLabel("2D Float List");

        NewLine();
        Indent();

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

        indexToRemove = DrawInt(indexToRemove);
        if (DrawButton(SetDataSceneStrings.RemoveList))
        {
            twoDListData.float_2dlist.RemoveAt(indexToRemove);
            twoDListData.Set_float_2dlist();
        }

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

        NewLine(2);
        Indent();

        foreach (var subList in twoDListData.float_2dlist)
        {
            // Draw float_list_field
            if (DrawButton(SetDataSceneStrings.AddNewFloat))
            {
                subList.Add(0);
                twoDListData.Set_float_2dlist();
            }

            Indent();

            indexToRemove = DrawInt(indexToRemove);
            if (DrawButton(SetDataSceneStrings.RemoveIndexLbl))
            {
                subList.RemoveAt(indexToRemove);
                twoDListData.Set_float_2dlist();
            }

            NewLine();
            Indent(2);

            for (var i = 0; i < subList.Count; i++)
            {
                if (i > 0)
                {
                    DrawLabel("|");
                }

                float oldVal = subList[i];
                subList[i] = DrawFloat(subList[i]);

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

            NewLine(2);
            Indent();
        }

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