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