/// <summary> /// DrawAssetNodes /// </summary> private void DrawAssetNodes() { mScrollViewPosition = EditorGUILayout.BeginScrollView(mScrollViewPosition); for (int i = 0; i < mAsmdefs.Count; i++) { EditorGUILayout.BeginHorizontal(); EditorGUILayout.LabelField(string.Format("{0}. 【{1}】", (i + 1).PadLeft(mAsmdefs.Count), mAsmdefs[i].name)); mAsmdefs[i].assetNode.isHotfix = EditorGUILayout.ToggleLeft("isHotfix", mAsmdefs[i].assetNode.isHotfix); if (GUILayout.Button("Setting")) { EditorStrayFogApplication.PingObject(mAsmdefs[i].assetNode); } if (GUILayout.Button("Brower")) { EditorStrayFogApplication.PingObject(mAsmdefs[i].path); } if (GUILayout.Button("Reveal")) { EditorStrayFogApplication.RevealInFinder(mAsmdefs[i].path); } EditorGUILayout.EndHorizontal(); } EditorGUILayout.EndScrollView(); if (GUILayout.Button("Export Asmdef Map To XLS")) { EditorStrayFogExecute.ExecuteAsmdefToXLS(); EditorUtility.DisplayDialog("Asmdef Map", "ExportAsmdefMapToXLS successed.", "OK"); } }
/// <summary> /// DrawAssetNodes /// </summary> private void DrawAssetNodes() { mScrollViewPosition = EditorGUILayout.BeginScrollView(mScrollViewPosition); for (int i = 0; i < mXlsTableSchemas.Count; i++) { EditorGUILayout.BeginHorizontal(); EditorGUILayout.LabelField(string.Format("{0}. 【{1}】{2}", (i + 1).PadLeft(mXlsTableSchemas.Count), mXlsTableSchemas[i].dbName, mXlsTableSchemas[i].tableName)); if (GUILayout.Button("Setting")) { EditorStrayFogApplication.PingObject(mXlsTableSchemas[i].tableSchemaAssetPath); } mXlsTableSchemas[i].isDeterminant = EditorGUILayout.ToggleLeft("是否是行列式表", mXlsTableSchemas[i].isDeterminant); mXlsTableSchemas[i].canModifyData = EditorGUILayout.ToggleLeft("是否可修改数据", mXlsTableSchemas[i].canModifyData); EditorUtility.SetDirty(mXlsTableSchemas[i]); if (GUILayout.Button("Brower")) { EditorStrayFogApplication.PingObject(mXlsTableSchemas[i].fileName); } if (GUILayout.Button("Reveal")) { EditorStrayFogApplication.RevealInFinder(mXlsTableSchemas[i].fileName); } if (GUILayout.Button("Open")) { EditorStrayFogApplication.OpenFile(Path.GetFullPath(mXlsTableSchemas[i].fileName)); } if (GUILayout.Button("Script")) { EditorStrayFogApplication.RevealInFinder(mXlsTableSchemas[i].scriptSqliteEntityFolder); } EditorGUILayout.EndHorizontal(); } EditorGUILayout.EndScrollView(); if (GUILayout.Button("Export Xls Schema To Sqlite")) { EditorStrayFogExecute.ExecuteExportXlsSchemaToSqlite(); EditorUtility.DisplayDialog("XlsSchema", "ExecuteExportXlsSchemaToSqlite successed.", "OK"); } }
/// <summary> /// 绘制GUI /// </summary> public void DrawGUI() { mTempIsDirty = false; mTempPaths.Clear(); if (paths != null && paths.Length > 0) { mTempPaths.AddRange(paths); } EditorGUILayout.LabelField(drawGUIDesc); #region Add Path if (GUILayout.Button("Add " + classify.ToString())) { if (mTempPaths.Count < allowOprNum) { #region Add string path = string.Empty; string error = string.Empty; string ext = string.Empty; List <string> legalExts = new List <string>(); bool isLegalFileExt = false; FileExtAttribute fextAttr = null; switch (classify) { case enEditorSavedAssetClassify.File: path = EditorUtility.OpenFilePanel("Add " + classify.ToString(), EditorStrayFogApplication.assetsPath, ""); ext = Path.GetExtension(path); int[] legalFileExts = OnLegalFileExts(); if (legalFileExts != null && legalFileExts.Length > 0) { foreach (int fext in legalFileExts) { fextAttr = typeof(enFileExt).GetAttributeForConstField <FileExtAttribute>(fext); isLegalFileExt |= fextAttr.IsExt(ext); legalExts.Add(fextAttr.ext); } } if (!isLegalFileExt) { error = string.Format("The file must be 【{0}】", string.Join(",", legalExts.ToArray())); } break; case enEditorSavedAssetClassify.Folder: path = EditorUtility.OpenFolderPanel("Add " + classify.ToString(), EditorStrayFogApplication.assetsPath, ""); break; } bool isLegalPath = false; string errTip = string.Empty; #region 判定路径是否合法 switch (pattern) { case enEditorSavedAssetPattern.OnlyInAssets: isLegalPath = EditorStrayFogApplication.IsSubToAssets(path); if (isLegalPath) { path = EditorStrayFogApplication.GetRelativeToAssets(path); } errTip = "in"; break; case enEditorSavedAssetPattern.OnlyOutAssets: isLegalPath = !EditorStrayFogApplication.IsSubToAssets(path); errTip = "out"; break; } #endregion if (isLegalPath) { if (string.IsNullOrEmpty(error)) { if (!mTempPaths.Contains(path)) { mTempPaths.Add(path); mTempIsDirty = true; } } else { EditorUtility.DisplayDialog(classify.ToString(), error, "OK"); } } else { EditorUtility.DisplayDialog(classify.ToString(), classify.ToString() + " must be " + errTip + " 【" + EditorStrayFogApplication.assetsPath + "】", "OK"); } #endregion } else { EditorUtility.DisplayDialog("Add Error", $"Only allow operation {allowOprNum} {classify}", "OK"); } } #endregion #region Display and Delete if (mTempPaths.Count > 0) { int delIndex = -1; for (int i = 0; i < mTempPaths.Count; i++) { EditorGUILayout.BeginHorizontal(); EditorGUILayout.LabelField( string.Format("{0}.{1}", (i + 1).PadLeft(mTempPaths.Count), mTempPaths[i])); if (GUILayout.Button("Brower")) { EditorStrayFogApplication.PingObject(mTempPaths[i]); } if (GUILayout.Button("Reveal")) { EditorStrayFogApplication.RevealInFinder(mTempPaths[i]); } if (GUILayout.Button("Delete")) { if (EditorUtility.DisplayDialog("Delete " + classify.ToString(), "Are you sure to delete " + classify.ToString() + " 【" + mTempPaths[i] + "】", "OK", "Cancel")) { delIndex = i; break; } } EditorGUILayout.EndHorizontal(); } if (delIndex >= 0) { mTempPaths.RemoveAt(delIndex); mTempIsDirty = true; } } #endregion if (mTempIsDirty) { paths = mTempPaths.ToArray(); } OnDrawGUI(); GUILayout.HorizontalSlider(0, 0, 0, GUILayout.Height(1)); EditorGUILayout.Separator(); EditorGUILayout.Separator(); if (mTempIsDirty) { EditorUtility.SetDirty(this); } }