/// <summary> /// 创建预置 /// </summary> /// <param name="_prefab">prefab配置</param> void OnCreatePrefab(EditorEngineAssetConfig _prefab) { if (!EditorStrayFogUtility.assetBundleName.IsIllegalFile(_prefab.name)) { bool isCreate = true; if (File.Exists(_prefab.fileName)) { isCreate = EditorUtility.DisplayDialog("Exists Prefab", "The prefab '" + _prefab.fileName + "' already exists,are you sure want to cover it?", "Yes", "No"); } if (isCreate) { _prefab.CreateAsset(); GameObject prefab = PrefabUtility.LoadPrefabContents(_prefab.fileName); prefab.layer = LayerMask.NameToLayer("UI"); prefab.AddComponent <RectTransform>(); PrefabUtility.SaveAsPrefabAsset(prefab, _prefab.fileName); AssetDatabase.SaveAssets(); EditorStrayFogApplication.PingObject(prefab); EditorStrayFogApplication.ExecuteMenu_AssetsRefresh(); EditorUtility.DisplayDialog("Create New Window Prefab", "Create window prefab is complete.", "OK"); } } else { EditorUtility.DisplayDialog("Illegal Name", "Window Name is not legal.", "OK"); } }
/// <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> /// 是否有相同的脚本 /// </summary> /// <param name="_script">脚本</param> /// <param name="_winName">窗口名称</param> /// <returns>true:是,false:否</returns> bool OnSameScript(EditorTextAssetConfig _script, string _winName) { bool hasSame = false; if (mScriptConfig.paths != null && mScriptConfig.paths.Length > 0) { string directory = string.Empty; string name = string.Empty; string path = string.Empty; foreach (string p in mScriptConfig.paths) { name = OnGetName(_winName); directory = OnGetDirectory(p, _winName).TransPathSeparatorCharToUnityChar(); path = Path.Combine(directory, name + _script.extAttribute.ext).TransPathSeparatorCharToUnityChar(); if (!_script.directory.Equals(directory) && File.Exists(path)) { hasSame = true; EditorGUILayout.HelpBox("The same script in =>" + path, MessageType.Error); EditorStrayFogApplication.PingObject(path); break; } } } return(hasSame); }
/// <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> /// 绘制资源 /// </summary> /// <param name="_title">标题</param> /// <param name="_assets">资源</param> /// <param name="_scrollViewPosition">滚动视图位置</param> void DrawAssets(string _title, List <EditorEngineAssetConfig> _assets, ref Vector2 _scrollViewPosition) { if (_assets.Count > 0) { EditorGUILayout.LabelField(_title); _scrollViewPosition = EditorGUILayout.BeginScrollView(_scrollViewPosition); for (int i = 0; i < _assets.Count; i++) { EditorGUILayout.BeginHorizontal(); EditorGUILayout.LabelField( string.Format("{0}.{1}", (i + 1).PadLeft(_assets.Count), _assets[i].name )); if (_assets[i].Exists() && GUILayout.Button("Browse")) { EditorStrayFogApplication.PingObject(_assets[i].fileName); } EditorGUILayout.EndHorizontal(); } EditorGUILayout.EndScrollView(); } }
/// <summary> /// OnGUI /// </summary> void OnGUI() { mNewAssetName = EditorGUILayout.TextField("资源名称", mNewAssetName); if (!string.IsNullOrEmpty(mNewAssetName.Trim())) { mScriptConfig.SetName(mNewAssetName); mAssetConfig.SetName(mNewAssetName); mAssetConfig.SetType(mNewAssetName); EditorGUILayout.LabelField("1." + mScriptConfig.fileName); EditorGUILayout.LabelField("2." + mAssetConfig.fileName); mScriptContent = mTxtScriptTemplete.Replace("#ClassName#", mNewAssetName); mScriptConfig.SetText(mScriptContent); EditorGUILayout.HelpBox(mScriptContent, MessageType.Info); if (File.Exists(mAssetConfig.fileName)) { if (GUILayout.Button("Brower")) { EditorStrayFogApplication.PingObject(mAssetConfig.fileName); } } else if (EditorStrayFogAssembly.IsExistsTypeInApplication(mNewAssetName)) { if (GUILayout.Button("Create Asset")) { mAssetConfig.CreateAsset(); EditorUtility.DisplayDialog("Custom Asset ", string.Format("Create Asset【{0}】success , path is '{1}'.", mAssetConfig.name, mAssetConfig.fileName), "OK"); EditorStrayFogApplication.ExecuteMenu_AssetsRefresh(); } } else if (GUILayout.Button("Create Script")) { mScriptConfig.CreateAsset(); EditorStrayFogApplication.ExecuteMenu_AssetsRefresh(); } } }
/// <summary> /// 绘制节点 /// </summary> void DrawAssetNodes() { #region mSearchWindowName 搜索 mSearchWindowName = EditorGUILayout.TextField("Search Window Name", mSearchWindowName); #endregion EditorGUILayout.Separator(); #region RenderMode 窗口绘制类别 #region 批量选择 EditorGUILayout.BeginHorizontal(); if (GUILayout.Button("Selected All RenderMode")) { AdjustRenderModeSelected(1); } if (GUILayout.Button("UnSelected All RenderMode")) { AdjustRenderModeSelected(-1); } if (GUILayout.Button("Reverse All RenderMode")) { AdjustRenderModeSelected(0); } EditorGUILayout.EndHorizontal(); #endregion EditorGUILayout.Separator(); #region 显示操作 EditorGUILayout.BeginHorizontal(); EditorGUILayout.LabelField("Window Render Mode", GUILayout.ExpandWidth(false)); foreach (RenderMode rm in mRenderModes) { mSearchWindowRenderMode[(int)rm] = EditorGUILayout.ToggleLeft(rm.ToString(), mSearchWindowRenderMode[(int)rm], GUILayout.ExpandWidth(false)); } EditorGUILayout.EndHorizontal(); #endregion #endregion EditorGUILayout.Separator(); #region enUIWindowLayer 窗口层级 #region 批量选择 EditorGUILayout.BeginHorizontal(); if (GUILayout.Button("Selected All Layer")) { AdjustWindowMinLayerSelected(1); } if (GUILayout.Button("UnSelected All Layer")) { AdjustWindowMinLayerSelected(-1); } if (GUILayout.Button("Reverse All Layer")) { AdjustWindowMinLayerSelected(0); } EditorGUILayout.EndHorizontal(); #endregion EditorGUILayout.Separator(); #region 显示操作 EditorGUILayout.BeginHorizontal(); EditorGUILayout.LabelField("Window Layer", GUILayout.ExpandWidth(false)); mWindowMinLayerScrollViewPosition = EditorGUILayout.BeginScrollView(mWindowMinLayerScrollViewPosition, GUILayout.ExpandHeight(false)); EditorGUILayout.BeginHorizontal(); foreach (KeyValuePair <int, string> key in msrWindowMinLayerMaping) { mSearchWindowMinLayer[key.Key] = EditorGUILayout.ToggleLeft(key.Value, mSearchWindowMinLayer[key.Key], GUILayout.ExpandWidth(false)); } EditorGUILayout.EndHorizontal(); EditorGUILayout.EndScrollView(); EditorGUILayout.EndHorizontal(); #endregion #endregion EditorGUILayout.Separator(); #region isDraw 计算是否绘制 if (mWindows != null && mWindows.Count > 0) { for (int i = 0; i < mWindows.Count; i++) { mWindows[i].isDraw = //名称过滤 (string.IsNullOrEmpty(mSearchWindowName) || Regex.IsMatch(mWindows[i].nameWithoutExtension, string.Format(@"({0})+?\w*", mSearchWindowName.Replace(",", "|")), RegexOptions.IgnoreCase)) && //绘制类别过滤 mSearchWindowRenderMode[(int)mWindows[i].assetNode.renderMode] && //窗口最小Layer mSearchWindowMinLayer[(int)mWindows[i].assetNode.layer]; } } #endregion #region 绘制窗口属性列表 mRemoveWindows.Clear(); if (mWindows != null && mWindows.Count > 0) { mScrollViewPosition = EditorGUILayout.BeginScrollView(mScrollViewPosition); EditorGUILayout.BeginVertical(); for (int i = 0; i < mWindows.Count; i++) { if (mWindows[i].isDraw) { EditorGUILayout.BeginHorizontal(); #region 显示属性 EditorGUILayout.LabelField( string.Format("{0}=>【{1}】{2}", string.Format("{0}.{1}", (i + 1).PadLeft(mWindows.Count), mWindows[i].nameWithoutExtension), mWindows[i].assetNode.renderMode.ToString(), msrWindowMinLayerMaping[(int)mWindows[i].assetNode.layer] ) ); #endregion EditorGUILayout.EndHorizontal(); EditorGUILayout.BeginHorizontal(); #region Setting 按钮 if (GUILayout.Button("Setting")) { EditorStrayFogApplication.PingObject(mWindows[i].assetNode); } #endregion #region Brower 按钮 if (GUILayout.Button("Brower")) { EditorStrayFogApplication.PingObject(mWindows[i].path); } #endregion #region Select 按钮 if (GUILayout.Button("Select")) { mSearchWindowName = mWindows[i].nameWithoutExtension; } #endregion #region Delete 按钮 if (GUILayout.Button("Delete")) { int delScriptIndex = -1; if (EditorStrayFogSavedAssetConfig.setFolderConfigForUIWindowPrefab.paths != null && EditorStrayFogSavedAssetConfig.setFolderConfigForUIWindowPrefab.paths.Length > 0) { string path = Path.GetDirectoryName(mWindows[i].directory).TransPathSeparatorCharToUnityChar(); for (int p = 0; p < EditorStrayFogSavedAssetConfig.setFolderConfigForUIWindowPrefab.paths.Length; p++) { if (path.Equals(EditorStrayFogSavedAssetConfig.setFolderConfigForUIWindowPrefab.paths[i])) { delScriptIndex = p; break; } } } if (delScriptIndex >= 0) { string delPrefabDirectory = mWindows[i].directory; string delScriptDirectory = Path.Combine(EditorStrayFogSavedAssetConfig.setFolderConfigForUIWindowScript.paths[delScriptIndex], Path.GetFileName(mWindows[i].directory)); string delAssetPath = AssetDatabase.GetAssetPath(mWindows[i].assetNode); mSbInfo.Length = 0; mSbInfo.AppendLine("Do you want to delete window ?"); mSbInfo.AppendLine(string.Format("Window =>{0}", mWindows[i].path)); mSbInfo.AppendLine("It will delete follow asset:"); mSbInfo.AppendLine(string.Format("1. Del Prefab Folder => {0}", delPrefabDirectory)); mSbInfo.AppendLine(string.Format("2. Del Script Folder => {0}", delScriptDirectory)); mSbInfo.AppendLine(string.Format("3. Del Asset => {0}", delAssetPath)); mSbInfo.AppendLine(string.Format("4. Del SQLite UIWindowSetting Where id={0}", mWindows[i].winId)); if (EditorUtility.DisplayDialog("Delete", mSbInfo.ToString(), "Yes", "No")) { mRemoveWindows.Add(i); EditorStrayFogUtility.cmd.DeleteFolder(delPrefabDirectory); EditorStrayFogUtility.cmd.DeleteFolder(delScriptDirectory); File.Delete(delAssetPath); EditorStrayFogXLS.DeleteUIWindowSetting(mWindows[i].winId); break; } } } #endregion EditorGUILayout.EndHorizontal(); } } EditorGUILayout.EndVertical(); EditorGUILayout.EndScrollView(); if (mRemoveWindows.Count > 0) { foreach (int index in mRemoveWindows) { mWindows.RemoveAt(index); } BuilderWindowEnum(); } } #endregion #region 显示窗口 if (GUILayout.Button("Display UIWindow")) { mWindows = EditorStrayFogGlobalVariable.CollectUIWindowSettingAssets <EditorSelectionUIWindowSetting>(); } #endregion #region 保存设置 if (GUILayout.Button("Save Window Setting")) { BuilderWindowEnum(); } #endregion }
static void EditorQueryMenuItem_EditorWindowLookProjectSetting() { EditorStrayFogApplication.PingObject(enEditorApplicationFolder.Project_Resources.GetAttribute <EditorApplicationFolderAttribute>().path); }
/// <summary> /// DrawAssetNodes /// </summary> private void DrawAssetNodes() { mSelectConfigIndex = EditorGUILayout.Popup("Select Config", mSelectConfigIndex, mConfigIndexs.ToArray()); mWindowName = EditorGUILayout.TextField("Window Name", mWindowName); EditorGUILayout.Separator(); mValidateConfig = false; if (mPrefabConfig.paths != null && mPrefabConfig.paths.Length > mSelectConfigIndex) { mUIWindowPrefab.SetDirectory(OnGetDirectory(mPrefabConfig.paths[mSelectConfigIndex], mWindowName)); mUIWindowPrefab.SetName(OnGetName(mWindowName)); mValidateConfig = true; } if (mScriptConfig.paths != null && mScriptConfig.paths.Length > mSelectConfigIndex) { mUIWindowViewScript.SetDirectory(OnGetDirectory(mScriptConfig.paths[mSelectConfigIndex], mWindowName)); mUIWindowViewScript.SetName(OnGetName(mWindowName)); mValidateConfig &= true; } if (mValidateConfig) { #region 浏览按钮 EditorGUILayout.Separator(); EditorGUILayout.BeginHorizontal(); EditorGUILayout.LabelField(string.Format("1. {0}", mUIWindowViewScript.fileName)); if (GUILayout.Button("Brower")) { EditorStrayFogApplication.PingObject(mUIWindowViewScript.fileName); } EditorGUILayout.EndHorizontal(); EditorGUILayout.Separator(); EditorGUILayout.BeginHorizontal(); EditorGUILayout.LabelField(string.Format("2. {0}", mUIWindowPrefab.fileName)); if (GUILayout.Button("Brower")) { EditorStrayFogApplication.PingObject(mUIWindowPrefab.fileName); } EditorGUILayout.EndHorizontal(); #endregion EditorGUILayout.Separator(); if (!string.IsNullOrEmpty(mWindowName)) { if (!OnSameScript(mUIWindowViewScript, mWindowName)) { if (GUILayout.Button("Create Script")) { OnCreateScript(mUIWindowViewScript); } else if (File.Exists(mUIWindowViewScript.fileName) && GUILayout.Button("Create Prefab")) { if (!string.IsNullOrEmpty(mWindowName)) { OnCreatePrefab(mUIWindowPrefab); } } } } } else { EditorGUILayout.HelpBox(string.Format("There is no script config for 【{0}】", mPrefabConfig.paths[mSelectConfigIndex]), MessageType.Info); } }
static void EditorAnimCurveMenuItem_EditorWindowExecuteLookBuildHotfixAsmdefStaticSetting() { EditorEngineAssetConfig cfg = EditorStrayFogExecute.ExecuteLookBuildHotfixAsmdefStaticSetting(); EditorStrayFogApplication.PingObject(cfg.engineAsset); }
/// <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); } }