This commit is contained in:
Victor_Wang 2024-08-06 10:50:14 +08:00
parent 1efe849cbe
commit fc60e42677
5 changed files with 65 additions and 56 deletions

View File

@ -1,6 +0,0 @@
{
"version": "1.0",
"components": [
"Microsoft.VisualStudio.Workload.ManagedGame"
]
}

View File

@ -205,7 +205,7 @@ public class Tools
private static int GetKeyIndex(DataTable dataTable) private static int GetKeyIndex(DataTable dataTable)
{ {
DataRow row = dataTable.Rows[2]; DataRow row = dataTable.Rows[2];
for (int i = startIndex; i < dataTable.Columns.Count; i++) for (int i = 0; i < dataTable.Columns.Count; i++)
{ {
if (row[i].ToString() == "key") if (row[i].ToString() == "key")
{ {

View File

@ -24,6 +24,8 @@ public class D_Process : I_Enter, I_Exit
/// </summary> /// </summary>
public string processName; public string processName;
#endregion #endregion

View File

@ -67,6 +67,7 @@ public class ProcessManager : BaseManager<ProcessManager>
coroutine = GameManager.MonoMgr.StartCoroutine(CountDown(countDown)); coroutine = GameManager.MonoMgr.StartCoroutine(CountDown(countDown));
d_Scheme = DataManager.Instance.GetSchemeData(id); d_Scheme = DataManager.Instance.GetSchemeData(id);
ReportManager.Instance.creport = DataManager.Instance.GetSchemeReport(id); ReportManager.Instance.creport = DataManager.Instance.GetSchemeReport(id);
d_Scheme.Init(); d_Scheme.Init();
Debug.Log("流程初始化完成"); Debug.Log("流程初始化完成");
} }

View File

@ -19,8 +19,8 @@ public class AutoGenerate : EditorWindow
private Label titleText; private Label titleText;
private Label hintText; private Label hintText;
private Toggle testScene; private Toggle testScene; //测试场景是否生成
private Toggle spriteFile; //动态文件夹 private Toggle dynamicSprite; //动态文件夹是否生成
private Button generateBtn; private Button generateBtn;
private TextField nameInput; private TextField nameInput;
@ -30,11 +30,13 @@ public class AutoGenerate : EditorWindow
#region Path #region Path
private string scenePath; private string testScenePath;
private string scriptPath; private string scriptPath;
private string prefabPath; private string uiPrefabPath;
private string uiSpritePath; private string uiStaticSpritePath;
private string uiSpritePath1; private string uidynamicSpritePath;
private string uiTemplatePath;
#endregion #endregion
@ -48,11 +50,14 @@ public class AutoGenerate : EditorWindow
public void CreateGUI() public void CreateGUI()
{ {
scenePath = "Assets/SandBox/TestUIPanelScenes"; testScenePath = "Assets/SandBox/TestUIPanelScenes";
scriptPath = "Assets/Project/UI/UI_Panel"; scriptPath = "Assets/Project/UI/UI_Panel";
prefabPath = "Assets/Resources/UI/UI_Panel"; uiPrefabPath = "Assets/Resources/UI/UI_Panel";
uiSpritePath = "Assets/ArtRes/Sprite/UI_Panel"; uiStaticSpritePath = "Assets/ArtRes/Sprite/UI_Panel";
uiSpritePath1 = "Assets/Resources/Sprites"; uidynamicSpritePath = "Assets/Resources/Sprites";
uiTemplatePath = Path.Combine("Assets", "SandBox",
"TestUIPanelScenes", "OnlyUITemplate",
"CustomPanel.prefab");
// scenePath = "Assets/Test1"; // scenePath = "Assets/Test1";
// scriptPath = "Assets/Test2"; // scriptPath = "Assets/Test2";
// prefabPath = "Assets/Test3"; // prefabPath = "Assets/Test3";
@ -65,13 +70,10 @@ public class AutoGenerate : EditorWindow
titleText = new Label("自动生成ui预制体,脚本,静态sprite文件夹,动态sprite文件夹(可选),测试场景(可选),"); titleText = new Label("自动生成ui预制体,脚本,静态sprite文件夹,动态sprite文件夹(可选),测试场景(可选),");
hintText = new Label(""); hintText = new Label("");
testScene = new Toggle(); testScene = new Toggle("创建测试场景?");
testScene.label = "创建测试场景?"; dynamicSprite = new Toggle("创建动态sprite文件夹?");
spriteFile = new Toggle(); generateBtn = new Button(OnGenerateButtonClick);
spriteFile.label = "创建动态sprite文件夹?";
generateBtn = new Button();
generateBtn.text = "自动生成按钮"; generateBtn.text = "自动生成按钮";
nameInput = new TextField("预制体名(也是脚本名)"); nameInput = new TextField("预制体名(也是脚本名)");
@ -79,31 +81,21 @@ public class AutoGenerate : EditorWindow
root.Add(titleText); root.Add(titleText);
root.Add(hintText); root.Add(hintText);
root.Add(testScene); root.Add(testScene);
root.Add(spriteFile); root.Add(dynamicSprite);
root.Add(nameInput); root.Add(nameInput);
root.Add(generateBtn); root.Add(generateBtn);
// rootVisualElement.Add(rootElement);
// generateBtn = rootElement.Q<Button>("AutoGenerate");
// hintText = rootElement.Q<Label>("HintTitle");
// nameInput = rootElement.Q<TextField>("NameInput"); // nameInput = rootElement.Q<TextField>("NameInput");
generateBtn.clicked += () => { OnGenerateButtonClick(); };
} }
private void OnGenerateButtonClick() private void OnGenerateButtonClick()
{ {
CheckDirectoryAndCreat(); CheckDirectoryAndCreat(); //检查五个路径文件夹是否都在,没有则创建
string tempName = nameInput.text; string tempName = nameInput.text;
if (string.IsNullOrWhiteSpace(tempName))
{
ShowHint("输入文件名异常,未添加任何文件");
return;
}
var sceneExist = DoesFileExist(scenePath, tempName);
var preExist = DoesFileExist(prefabPath, tempName); var sceneExist = DoesFileExist(testScenePath, tempName);
var preExist = DoesFileExist(uiPrefabPath, tempName);
var scriptExist = DoesFileExist(scriptPath, tempName); var scriptExist = DoesFileExist(scriptPath, tempName);
if (sceneExist || preExist || scriptExist) if (sceneExist || preExist || scriptExist)
{ {
@ -114,16 +106,15 @@ public class AutoGenerate : EditorWindow
CreatPrefab(tempName); CreatPrefab(tempName);
CreatCSFile(tempName); CreatCSFile(tempName);
DirectoryDontExist(uiSpritePath + "/" + tempName); DirectoryDontExistAndCreat(uiStaticSpritePath + "/" + tempName);
if (spriteFile.value) if (dynamicSprite.value)
{ {
DirectoryDontExist(uiSpritePath1+"/"+tempName); DirectoryDontExistAndCreat(uidynamicSpritePath + "/" + tempName);
} }
AssetDatabase.Refresh();
if (testScene.value) if (testScene.value)
{ {
CreateNewScene(scenePath, tempName); CreateNewScene(testScenePath, tempName);
} }
// TODO 绑定脚本的功能没实现AttachScriptToGameObject(tempName, generatePre); // TODO 绑定脚本的功能没实现AttachScriptToGameObject(tempName, generatePre);
@ -142,16 +133,36 @@ public class AutoGenerate : EditorWindow
//EditorUtility.DisplayDialog("成功创建", $" " + scenePath, "OK"); //EditorUtility.DisplayDialog("成功创建", $" " + scenePath, "OK");
} }
private void CheckDirectoryAndCreat() //TODO
private bool CheckLawfulString(string checkedString)
{ {
DirectoryDontExist(prefabPath); if (string.IsNullOrWhiteSpace(checkedString))
DirectoryDontExist(scenePath); {
DirectoryDontExist(scriptPath); ShowHint("输入文件名异常,未添加任何文件");
DirectoryDontExist(uiSpritePath); return false;
DirectoryDontExist(uiSpritePath1); }
foreach (var strItem in checkedString)
{
if (strItem == '1')
{
return false;
}
}
return true;
} }
private void DirectoryDontExist(string directoryPath) private void CheckDirectoryAndCreat()
{
DirectoryDontExistAndCreat(uiPrefabPath);
DirectoryDontExistAndCreat(testScenePath);
DirectoryDontExistAndCreat(scriptPath);
DirectoryDontExistAndCreat(uidynamicSpritePath);
DirectoryDontExistAndCreat(uiStaticSpritePath);
}
private void DirectoryDontExistAndCreat(string directoryPath)
{ {
if (!Directory.Exists(directoryPath)) if (!Directory.Exists(directoryPath))
{ {
@ -168,9 +179,7 @@ public class AutoGenerate : EditorWindow
private void CreatPrefab(string preName) private void CreatPrefab(string preName)
{ {
//Selection.activeGameObject; //Selection.activeGameObject;
GameObject selectedObjectRes = AssetDatabase.LoadAssetAtPath<GameObject>(Path.Combine("Assets", "SandBox", GameObject selectedObjectRes = AssetDatabase.LoadAssetAtPath<GameObject>(uiTemplatePath);
"TestUIPanelScenes", "OnlyUITemplate",
"CustomPanel.prefab"));
if (selectedObjectRes == null) if (selectedObjectRes == null)
{ {
@ -180,12 +189,13 @@ public class AutoGenerate : EditorWindow
GameObject selectedObject = (GameObject)PrefabUtility.InstantiatePrefab(selectedObjectRes); GameObject selectedObject = (GameObject)PrefabUtility.InstantiatePrefab(selectedObjectRes);
PrefabUtility.UnpackPrefabInstance(selectedObject, PrefabUnpackMode.Completely, PrefabUtility.UnpackPrefabInstance(selectedObject, PrefabUnpackMode.Completely,
InteractionMode.AutomatedAction); InteractionMode.AutomatedAction); //完全解包&不提示
//解包属性会出问题?
selectedObject.transform.localPosition = Vector3.zero; selectedObject.transform.localPosition = Vector3.zero;
selectedObject.transform.localScale = Vector3.one; selectedObject.transform.localScale = Vector3.one;
selectedObject.name = preName; selectedObject.name = preName;
var generatePre = var generatePre =
PrefabUtility.SaveAsPrefabAsset(selectedObject, Path.Combine(prefabPath, preName + ".prefab")); PrefabUtility.SaveAsPrefabAsset(selectedObject, Path.Combine(uiPrefabPath, preName + ".prefab"));
} }
private string GetScriptTemplate(string scriptName) private string GetScriptTemplate(string scriptName)
@ -243,12 +253,13 @@ public void Init()
/// <param name="path"></param> /// <param name="path"></param>
/// <param name="fileName"></param> /// <param name="fileName"></param>
/// <returns></returns> /// <returns></returns>
public bool DoesFileExist(string path, string fileName) private bool DoesFileExist(string path, string fileName)
{ {
string fullPath = path; string fullPath = path;
string[] files = Directory.GetFiles(fullPath, "*.*", SearchOption.TopDirectoryOnly); //不递归 string[] files = Directory.GetFiles(fullPath, "*.*", SearchOption.TopDirectoryOnly); //不递归
foreach (var file in files) foreach (var file in files)
{ {
//无拓展名
if (Path.GetFileNameWithoutExtension(file) == fileName) if (Path.GetFileNameWithoutExtension(file) == fileName)
{ {
return true; return true;
@ -300,6 +311,7 @@ public void Init()
EditorSceneManager.SaveScene(newScene, scenePath + "/" + sceneName + ".unity", true); EditorSceneManager.SaveScene(newScene, scenePath + "/" + sceneName + ".unity", true);
} }
//暂时拿不到
private void AttachScriptToGameObject(string className, GameObject pre) private void AttachScriptToGameObject(string className, GameObject pre)
{ {
// 获取当前的Assembly // 获取当前的Assembly