This commit is contained in:
2025-09-24 17:16:12 +08:00
parent 5e7c399e4d
commit f9575180f3
2 changed files with 21 additions and 12 deletions

View File

@@ -51,6 +51,7 @@ public class UICreateWindow : EditorWindow
private string _uiViewTemplate = "UIViewTemplate";
private string _uiConfig = "UIConfig";
private string _uiName;
private string _saveUIPath;
public GameObject uiPrefab;
private Dictionary<string, string> _uiNames = new Dictionary<string, string>();
private Dictionary<string, UIConfigJson> _uiJsonDatas = new Dictionary<string, UIConfigJson>();
@@ -77,6 +78,7 @@ public class UICreateWindow : EditorWindow
_uiJsonDatas.Clear();
_uiNames.Clear();
uiViews = ReflectionHelper.GetAllUIViewTypes(_domainNames[_domainIndex]);
_saveUIPath = EditorPrefs.GetString(nameof(_saveUIPath));
DomainPathField();
foreach (var uiView in uiViews)
{
@@ -89,6 +91,7 @@ public class UICreateWindow : EditorWindow
_uiNames.AddOrUpdate(str, scriptPath);
}
}
private void OnGUI()
{
EditorGUILayout.LabelField("通过[Evo/UI管理]可以打开");
@@ -106,12 +109,13 @@ public class UICreateWindow : EditorWindow
{
_scroll2 = EditorGUILayout.BeginScrollView(_scroll2, "box", GUILayout.Width(position.width * 0.4f - 6));
{
var tempIndex =EditorGUILayout.Popup("Domain", _domainIndex, _domainNames);
var tempIndex = EditorGUILayout.Popup("Domain", _domainIndex, _domainNames);
if (tempIndex != _domainIndex)
{
ValueChang();
_domainIndex = tempIndex;
}
EditorGUILayout.HelpBox("已创建的UI", MessageType.Info);
_mInput = EditorGUILayout.TextField(_mInput, EditorStyles.toolbarSearchField, GUILayout.Height(20));
@@ -127,6 +131,7 @@ public class UICreateWindow : EditorWindow
{
jsonData = new UIConfigJson();
}
if (string.IsNullOrEmpty(scriptPath)) continue;
var defaultColor = GUI.color;
@@ -160,16 +165,21 @@ public class UICreateWindow : EditorWindow
var uiScriptPath = GetUIScript(_uiName);
if (string.IsNullOrEmpty(uiScriptPath))
{
var saveUIPath= $"Assets/Domain/{_domainNames[_domainIndex]}/Scripts/UI";
if (GUILayout.Button($"选择创建路径:{saveUIPath}"))
if (string.IsNullOrEmpty(_saveUIPath))
{
var newPath = EditorUtility.OpenFolderPanel("UI生成路径", saveUIPath, "");
saveUIPath = newPath.Replace(Application.dataPath, "Assets");
_saveUIPath = $"Assets/Domain/{_domainNames[_domainIndex]}/HotUpdate/UI";
}
if (GUILayout.Button($"选择创建路径:{_saveUIPath}"))
{
var newPath = EditorUtility.OpenFolderPanel("UI生成路径", _saveUIPath, "");
_saveUIPath = newPath.Replace(Application.dataPath, "Assets");
EditorPrefs.SetString(nameof(_saveUIPath), _saveUIPath);
}
if (uiPrefab != null)
{
EditorGUILayout.TextField("UI生成路径", $"{saveUIPath}/{_uiName}.cs");
EditorGUILayout.TextField("UI生成路径", $"{_saveUIPath}/{_uiName}.cs");
}
_isWindow = EditorGUILayout.Toggle("是否为窗口", _isWindow);
@@ -189,7 +199,7 @@ public class UICreateWindow : EditorWindow
str = Regex.Replace(str, "//UIControlData",
uiControlData != null ? UnityEngine.GUIUtility.systemCopyBuffer : "");
string newPath = $"{saveUIPath}/{_uiName}.cs";
string newPath = $"{_saveUIPath}/{_uiName}.cs";
File.WriteAllText(newPath, str);
var jsonData = new UIConfigJson
@@ -227,6 +237,7 @@ public class UICreateWindow : EditorWindow
jsonData.uiType = _uiName;
_uiJsonDatas.AddOrUpdate(_uiName, jsonData);
}
if (UnityEditor.PrefabUtility.IsPartOfPrefabAsset(uiPrefab))
{
// 预制体资源就是自身
@@ -335,7 +346,7 @@ public class UICreateWindow : EditorWindow
return string.Empty;
}
// if (GetUIJson(name) == null) return string.Empty;
// if (GetUIJson(name) == null) return string.Empty;
string[] ids = AssetDatabase.FindAssets(name);
if (ids != null)
@@ -438,6 +449,7 @@ static class ReflectionHelper
Debug.LogError($"未找到名为HotUpdate_{domainName}的程序集");
return null;
}
try
{
result.AddRange(targetAssembly.GetTypes()
@@ -465,7 +477,4 @@ static class ReflectionHelper
return result;
}
}

View File

@@ -1,7 +1,7 @@
{
"name": "com.staryevo.uifarme",
"displayName": "06.UIFarme",
"version": "2.0.3",
"version": "2.0.4",
"description": "UI框架工具",
"unity": "2021.3",
"unityRelease": "30f1",