Beispiel #1
0
    // Use this for initialization
    void Start()
    {
        //Here i save form in "Assets" folder for test, you can change it where you like.
        mSavePath = Application.dataPath + "/GameConfig.txt";

        if (File.Exists(mSavePath))
        {
            mForm = OOFormArray.ReadFromFile(mSavePath);
        }
        else
        {
            mForm = OOFormArray.ReadFromResources("OOForm/Tables/GameConfig");
        }

        //read data by column string name
        int run_times = mForm.GetInt("Value", "RUN_TIMES") + 1;

        mForm.SetInt(run_times, "Value", "RUN_TIMES");
        Save();

        //Read data by enum
        mIsTick = mForm.GetBool("Value", "IS_TICK");

        mWindowRect = mForm.GetRect("Value", "WINDOW_RECT");

        Debug.Log(mWindowRect.ToString());
    }
Beispiel #2
0
    private static OOFormArray DataTable2OOFormArray(DataTable dt)
    {
        OOFormArray form = new OOFormArray();

        // csv = "";
        form = InitForm(dt);
        int colNum = dt.Columns.Count;
        int rowNum = dt.Rows.Count;

        for (int r = 0; r < rowNum; r++)
        {
            var dr = dt.Rows[r];
            for (int c = 0; c < colNum; c++)
            {
                string      cName = dt.Columns[c].ColumnName;
                int         row   = r + 1;
                int         col   = c;
                System.Type tp    = dt.Columns[c].DataType;
                //print(tp);
                if (tp == typeof(int))
                {
                    int  val  = (int)dr[c];
                    bool bSet = form.SetInt(val, col, row);
                    // print("Set Int:" + val.ToString() + " OK?" + bSet.ToString());
                }
                else if (tp == typeof(Vector2))
                {
                    Vector2 val  = (Vector2)dr[c];
                    bool    bSet = form.SetVector2(val, col, row);
                    //print("Set Vec2:" + val.ToString() + " OK?" + bSet.ToString());
                }
                else if (tp == typeof(Vector3))
                {
                    Vector3 val  = (Vector3)dr[c];
                    bool    bSet = form.SetVector3(val, col, row);
                    //print("Set Vec3:" + val.ToString() + " OK?" + bSet.ToString());
                }
                else if (tp == typeof(Vector4))
                {
                    Vector4 val  = (Vector4)dr[c];
                    bool    bSet = form.SetVector4(val, col, row);
                    //print("Set Vec4:" + val.ToString() + " OK?" + bSet.ToString());
                }
                else if (tp == typeof(string))
                {
                    string val  = (string)dr[c];
                    bool   bSet = form.SetString(val, col, row);
                    //print("Set String:" + val + " OK?" + bSet.ToString());
                }
                else if (tp == typeof(float))
                {
                    float val  = (float)dr[c];
                    bool  bSet = form.SetFloat(val, col, row);
                    //   print("Set Float:" + val + " OK?" + bSet.ToString());
                }
                else if (tp == typeof(Rect))
                {
                    Rect val  = (Rect)dr[c];
                    bool bSet = form.SetRect(val, col, row);
                    // print("Set Rect:" + val + " OK?" + bSet.ToString());
                }
                else if (tp == typeof(bool))
                {
                    bool val  = (bool)dr[c];
                    bool bSet = form.SetBool(val, col, row);
                    //print("Set Bool:" + val + " OK?" + bSet.ToString());
                }

                else
                {
                    int  val  = (int)dr[c];
                    bool bSet = form.SetInt(val, col, row);
                }
            }
        }
        return(form);
    }