/// <summary> /// Show table in table view. /// </summary> /// <param name="idx"></param> void ShowTableData(int idx) { if (mFormManager == null) { return; } if (mFormManager.mTableList.Count > 0) { if (idx < mFormManager.mTableList.Count) { if (idx < 0) { idx = GetFirst(); } mCurrentColumnPage = 1; mCurrentRowPage = 1; mSelectionIndex = idx; mSelectionAsset = mFormManager.mTableList[idx]; mSelectionAssetPath = AssetDatabase.GetAssetPath(mSelectionAsset.GetInstanceID()); mSelectionTable = OOFormArray.ReadFromFile(mSelectionAssetPath); } } }
// 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()); }
// 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 + "/RuntimeTable.txt"; if (File.Exists(mSavePath)) { mForm = OOFormArray.ReadFromFile(mSavePath); } else { mForm = OOFormArray.ReadFromResources("OOForm/Tables/RuntimeTable"); } }
void DrawToolBar() { GUILayout.BeginHorizontal(EditorStyles.toolbar, GUILayout.ExpandWidth(true)); //2A+ GUILayout.BeginHorizontal(GUILayout.Width(mLeftBarWidth - 6)); //2B+ GUI.SetNextControlName("ForFouce"); _mAsset = mSelectionAsset; mSelectionAsset = (TextAsset)EditorGUILayout.ObjectField(mSelectionAsset, typeof(TextAsset), false); if (_mAsset != mSelectionAsset) { ReadFromTextAsset(); } GUILayout.EndHorizontal(); //2B- GUILayout.BeginHorizontal(GUILayout.ExpandWidth(true)); //2C+ if (mSelectionAsset != null) { if (GUILayout.Button("Import", EditorStyles.toolbarDropDown, GUILayout.Width(65))) { GUIContent[] menuItems = new GUIContent[] { new GUIContent("from OOForm table..."), new GUIContent("from Json..."), new GUIContent("from XML..."), new GUIContent("from CSV...") }; EditorUtility.DisplayCustomMenu(new Rect(mLeftBarWidth, 16, 0, 0), menuItems, -1, delegate(object userData, string[] options, int selected) { switch (selected) { case 0: { string path = EditorUtility.OpenFilePanel("Select file to import!", "", "txt"); if (path != "") { mSelectionTable = OOFormArray.ReadFromFile(path); mIsModify = true; } } break; case 1: { string path = EditorUtility.OpenFilePanel("Select file to import!", "", "txt"); if (path != "") { mSelectionTable = OOFormArray.ReadFromJsonFile(path); mIsModify = true; } } break; case 2: { string path = EditorUtility.OpenFilePanel("Select file to import!", "", "xml"); if (path != "") { mSelectionTable = OOFormArray.ReadFromXMLFile(path); mIsModify = true; } } break; case 3: { string path = EditorUtility.OpenFilePanel("Select file to import!", "", "csv"); if (path != "") { mSelectionTable = OOFormArray.ReadFormCSVFile(path); mIsModify = true; } } break; } } , null); } if (GUILayout.Button("Export", EditorStyles.toolbarDropDown, GUILayout.Width(65))) { GUIContent[] menuItems = new GUIContent[] { new GUIContent("to OOForm table..."), new GUIContent("to Json..."), new GUIContent("to XML..."), new GUIContent("to CSV...") }; EditorUtility.DisplayCustomMenu(new Rect(mLeftBarWidth + 65, 16, 0, 0), menuItems, -1, delegate(object userData, string[] options, int selected) { switch (selected) { case 0: { string path = EditorUtility.SaveFilePanel("Select file to save!", "", "", "txt"); if (path != "") { OOFormTools.WriteFileText(path, mSelectionTable.ToString()); } } break; case 1: { string path = EditorUtility.SaveFilePanel("Select file to save!", "", "", "txt"); if (path != "") { OOFormTools.WriteFileText(path, mSelectionTable.ToJsonString()); } } break; case 2: { string path = EditorUtility.SaveFilePanel("Select file to save!", "", "", "xml"); if (path != "") { OOFormTools.WriteFileText(path, mSelectionTable.ToXMLString(), System.Text.Encoding.UTF8); } } break; case 3: { string path = EditorUtility.SaveFilePanel("Select file to save!", "", "", "csv"); if (path != "") { OOFormTools.WriteFileText(path, mSelectionTable.ToCSVString(), System.Text.Encoding.UTF8); } } break; } } , null); } GUILayout.Label(""); GUILayout.Label("Search:", GUILayout.Width(50)); mSearchString = GUILayout.TextField(mSearchString, OOFormSkin.OStyle_ToolbarSearch, GUILayout.Width(120)); GUILayout.Label("", OOFormSkin.OStyle_ToolbarSearchRightCap); GUILayout.Label(" Column Page:", GUILayout.ExpandWidth(false)); if (GUILayout.Button("<", EditorStyles.toolbarButton, GUILayout.Width(40))) { mCurrentColumnPage--; mCurrentColumnPage = Mathf.Max(mCurrentColumnPage, 1); GUI.FocusControl("ForFouce"); } int max_column_page = mSelectionTable.mColumnCount / mPageColumnCount + 1; GUILayout.Label(mCurrentColumnPage.ToString() + "/" + max_column_page.ToString(), EditorStyles.textField, GUILayout.Width(50)); if (GUILayout.Button(">", EditorStyles.toolbarButton, GUILayout.Width(40))) { mCurrentColumnPage++; mCurrentColumnPage = Mathf.Min(mCurrentColumnPage, max_column_page); GUI.FocusControl("ForFouce"); } } GUILayout.EndHorizontal(); //2C- GUILayout.EndHorizontal(); //2A- }