111
This commit is contained in:
@@ -1,16 +1,17 @@
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using Sirenix.OdinInspector;
|
||||
using Sirenix.OdinInspector.Editor;
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
using UnityEngine.Serialization;
|
||||
|
||||
namespace Stary.Evo.Editor
|
||||
{
|
||||
public class ArtServerManageWindow : OdinEditorWindow
|
||||
{
|
||||
|
||||
[MenuItem("Evo/Art/服务器数据管理工具", false, 2)]
|
||||
static void Init()
|
||||
{
|
||||
@@ -19,25 +20,39 @@ namespace Stary.Evo.Editor
|
||||
window.Show();
|
||||
}
|
||||
|
||||
[TitleGroup("创建Art作用域")] public string domain;
|
||||
[EnumToggleButtons, HideLabel] [OnValueChanged("SetUseTypeData")]
|
||||
public UseType useType = UseType.Member;
|
||||
|
||||
[TitleGroup("创建Art作用域")]
|
||||
[Button("创建Art", ButtonSizes.Large)]
|
||||
public async void CreatDomain()
|
||||
private string _titleGroupName;
|
||||
|
||||
[TitleGroup("@ _titleGroupName")] public string productName;
|
||||
|
||||
[TitleGroup("@ _titleGroupName")]
|
||||
[Button("@ _titleGroupName", ButtonSizes.Large)]
|
||||
public void CreatDomain()
|
||||
{
|
||||
// if (GetCreatDomainAll().Count>0)
|
||||
// {
|
||||
// EditorUtility.DisplayDialog("错误!", "Domain仅可以创建一个,请在下方删除存在的Domain", "确定");
|
||||
// return;
|
||||
// }
|
||||
if (useType == UseType.Member)
|
||||
{
|
||||
CreatMemberFiled();
|
||||
}
|
||||
else if (useType == UseType.Project)
|
||||
{
|
||||
CreatArtFiled();
|
||||
}
|
||||
}
|
||||
|
||||
if (string.IsNullOrEmpty(domain))
|
||||
/// <summary>
|
||||
/// 创建项目目录
|
||||
/// </summary>
|
||||
private void CreatArtFiled()
|
||||
{
|
||||
if (string.IsNullOrEmpty(productName))
|
||||
{
|
||||
EditorUtility.DisplayDialog("错误!", "请输入将要创建Art的编号", "确定");
|
||||
return;
|
||||
}
|
||||
|
||||
string artDomainPath = $"{Application.dataPath}/Art/{domain}";
|
||||
string artDomainPath = $"{Application.dataPath}/Art/{productName}";
|
||||
if (!Directory.Exists(artDomainPath))
|
||||
{
|
||||
Directory.CreateDirectory(artDomainPath);
|
||||
@@ -64,9 +79,6 @@ namespace Stary.Evo.Editor
|
||||
//创建Textures文件夹
|
||||
CreatDirectory(artDomainPath + "/Textures");
|
||||
|
||||
//创建Config文件夹
|
||||
CreatDirectory(artDomainPath + "/Config");
|
||||
|
||||
File.WriteAllTextAsync(
|
||||
$"{artDomainPath}/这里放所有美术的资源,因涉及打包依赖等原因,不建议在上一层节点新增文件夹,如涉及文件夹规范等问题请@张铮.hint", "");
|
||||
}
|
||||
@@ -78,6 +90,7 @@ namespace Stary.Evo.Editor
|
||||
{
|
||||
Directory.CreateDirectory(sceneDir);
|
||||
}
|
||||
|
||||
/* 3. 创建新场景 */
|
||||
var newScene = UnityEditor.SceneManagement.EditorSceneManager.NewScene(
|
||||
UnityEditor.SceneManagement.NewSceneSetup.DefaultGameObjects,
|
||||
@@ -98,85 +111,234 @@ namespace Stary.Evo.Editor
|
||||
spawned.name = "RKCameraRigTest";
|
||||
|
||||
/* 6. 保存场景 */
|
||||
string scenePath = Path.Combine("Assets/Art", domain, "Scenes", "TestScene.unity");
|
||||
string scenePath = Path.Combine("Assets/Art", productName, "Scenes", "TestScene.unity");
|
||||
UnityEditor.SceneManagement.EditorSceneManager.SaveScene(newScene, scenePath);
|
||||
//创建Art 测试场景配置文件
|
||||
string configDir = $"{artDomainPath}/Config";
|
||||
if (!Directory.Exists(configDir))
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 创建成员目录
|
||||
/// </summary>
|
||||
private void CreatMemberFiled()
|
||||
{
|
||||
if (string.IsNullOrEmpty(productName))
|
||||
{
|
||||
Directory.CreateDirectory(configDir);
|
||||
EditorUtility.DisplayDialog("错误!", "请输入将要创建成员的编号", "确定");
|
||||
return;
|
||||
}
|
||||
|
||||
//检测成员是否存在
|
||||
bool isExit = false;
|
||||
foreach (var domainEntity in domainMemberList)
|
||||
{
|
||||
if (domainEntity.DomainName == productName)
|
||||
{
|
||||
isExit = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (isExit)
|
||||
{
|
||||
EditorUtility.DisplayDialog("错误!", "当前成员已在服务器中存在,无需重复创建", "确定");
|
||||
return;
|
||||
}
|
||||
|
||||
string memberDomainPath = $"{Application.dataPath}/Member/{productName}";
|
||||
if (!Directory.Exists(memberDomainPath))
|
||||
{
|
||||
Directory.CreateDirectory(memberDomainPath);
|
||||
|
||||
|
||||
//创建Config文件夹
|
||||
CreatDirectory(memberDomainPath + "/Config");
|
||||
//创建Scenes文件夹
|
||||
CreatDirectory(memberDomainPath + "/Scenes");
|
||||
|
||||
File.WriteAllTextAsync(
|
||||
$"{memberDomainPath}/这里是成员打包目录,因涉及打包依赖等原因,不建议在上一层节点新增文件夹,如涉及文件夹规范等问题请@张铮.hint", "");
|
||||
}
|
||||
|
||||
//创建Art 测试场景配置文件
|
||||
string configDir = $"{memberDomainPath}/Config";
|
||||
//模块配置资源
|
||||
ArtSceneData artSceneData = CreateInstance<ArtSceneData>();
|
||||
|
||||
|
||||
AssetDatabase.CreateAsset(artSceneData, $"Assets/Art/{domain}/Config/ArtSceneData.asset");
|
||||
AssetDatabase.CreateAsset(artSceneData, $"Assets/Member/{productName}/Config/ArtSceneData.asset");
|
||||
|
||||
AssetDatabase.SaveAssets();
|
||||
AssetDatabase.Refresh();
|
||||
}
|
||||
|
||||
|
||||
[ShowIf("IsMember")]
|
||||
[ListDrawerSettings(DraggableItems = false, ShowFoldout = false, ShowPaging = false, ShowItemCount = false,
|
||||
HideRemoveButton = true, HideAddButton = true)]
|
||||
public List<CreatArtServerDomainEntity> domainList;
|
||||
public List<CreatMemberServerDomainEntity> domainMemberList;
|
||||
|
||||
[ShowIf("IsProject")]
|
||||
[ListDrawerSettings(DraggableItems = false, ShowFoldout = false, ShowPaging = false, ShowItemCount = false,
|
||||
HideRemoveButton = true, HideAddButton = true)]
|
||||
public List<CreatArtDomainEntity> artList;
|
||||
|
||||
protected override async void Initialize()
|
||||
{
|
||||
base.Initialize();
|
||||
if (domainList != null)
|
||||
domainList.Clear();
|
||||
SetUseTypeData();
|
||||
if (domainMemberList != null)
|
||||
{
|
||||
domainMemberList.Clear();
|
||||
}
|
||||
|
||||
domainMemberList = new List<CreatMemberServerDomainEntity>();
|
||||
var resDmainResponse = await ArtLoadAssetServer.GetServerDomainAll();
|
||||
foreach (var response in resDmainResponse)
|
||||
{
|
||||
string domainPath = $"{Application.dataPath}/Art/{response.DomainName}";
|
||||
var domainEntity = new CreatArtServerDomainEntity(domainList);
|
||||
domainEntity.SetDomainData(response.DomainName, domainPath,response, ArtLoadAssetServer.ip);
|
||||
domainList.Add(domainEntity);
|
||||
string domainPath = $"{Application.dataPath}/Member/{response.DomainName}";
|
||||
var domainEntity = new CreatMemberServerDomainEntity(domainMemberList);
|
||||
domainEntity.SetDomainData(response.DomainName, domainPath, response, ArtLoadAssetServer.ip);
|
||||
domainMemberList.Add(domainEntity);
|
||||
}
|
||||
|
||||
artList = GetCreatDomainAll();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
private static void CreatDirectory(string artDomainPath)
|
||||
{
|
||||
if (!Directory.Exists(artDomainPath))
|
||||
{
|
||||
//创建Animation文件夹
|
||||
Directory.CreateDirectory(artDomainPath);
|
||||
}
|
||||
}
|
||||
public static void CreateDomainDirectory(string domain)
|
||||
|
||||
public void CreateDomainDirectory(string domain)
|
||||
{
|
||||
string artDomainPath = $"{Application.dataPath}/Art/{domain}";
|
||||
string artDomainPath = "";
|
||||
if (useType == UseType.Member)
|
||||
{
|
||||
artDomainPath = $"{Application.dataPath}/Member/{domain}";
|
||||
}
|
||||
else if (useType == UseType.Project)
|
||||
{
|
||||
artDomainPath = $"{Application.dataPath}/Art/{domain}";
|
||||
}
|
||||
|
||||
if (!Directory.Exists(artDomainPath))
|
||||
{
|
||||
EditorUtility.DisplayDialog("提示", $"不存在此Domain:{domain},无法创建", "确定");
|
||||
return;
|
||||
}
|
||||
|
||||
//创建Animation文件夹
|
||||
CreatDirectory(artDomainPath + "/Animation");
|
||||
//创建Effects文件夹
|
||||
CreatDirectory(artDomainPath + "/Effects");
|
||||
//创建Fbx文件夹
|
||||
CreatDirectory(artDomainPath + "/Fbx");
|
||||
//创建Font文件夹
|
||||
CreatDirectory(artDomainPath + "/Font");
|
||||
//创建Materials文件夹
|
||||
CreatDirectory(artDomainPath + "/Materials");
|
||||
//创建Prefabs文件夹
|
||||
CreatDirectory(artDomainPath + "/Prefabs");
|
||||
//创建Scenes文件夹
|
||||
CreatDirectory(artDomainPath + "/Scenes");
|
||||
//创建/Scenes/Test文件夹
|
||||
CreatDirectory(artDomainPath + "/Scenes/Test");
|
||||
//创建Shader文件夹
|
||||
CreatDirectory(artDomainPath + "/Shader");
|
||||
//创建Textures文件夹
|
||||
CreatDirectory(artDomainPath + "/Textures");
|
||||
if (useType == UseType.Member)
|
||||
{
|
||||
//创建Config文件夹
|
||||
CreatDirectory(artDomainPath + "/Config");
|
||||
//创建Scenes文件夹
|
||||
CreatDirectory(artDomainPath + "/Scenes");
|
||||
//创建/Scenes/Test文件夹
|
||||
CreatDirectory(artDomainPath + "/Scenes/Test");
|
||||
}
|
||||
else if (useType == UseType.Project)
|
||||
{
|
||||
//创建Animation文件夹
|
||||
CreatDirectory(artDomainPath + "/Animation");
|
||||
//创建Effects文件夹
|
||||
CreatDirectory(artDomainPath + "/Effects");
|
||||
//创建Fbx文件夹
|
||||
CreatDirectory(artDomainPath + "/Fbx");
|
||||
//创建Font文件夹
|
||||
CreatDirectory(artDomainPath + "/Font");
|
||||
//创建Materials文件夹
|
||||
CreatDirectory(artDomainPath + "/Materials");
|
||||
//创建Prefabs文件夹
|
||||
CreatDirectory(artDomainPath + "/Prefabs");
|
||||
//创建Scenes文件夹
|
||||
CreatDirectory(artDomainPath + "/Scenes");
|
||||
//创建/Scenes/Test文件夹
|
||||
CreatDirectory(artDomainPath + "/Scenes/Test");
|
||||
//创建Shader文件夹
|
||||
CreatDirectory(artDomainPath + "/Shader");
|
||||
//创建Textures文件夹
|
||||
CreatDirectory(artDomainPath + "/Textures");
|
||||
}
|
||||
|
||||
AssetDatabase.Refresh();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取全部作用域
|
||||
/// </summary>
|
||||
private static List<CreatArtDomainEntity> GetCreatDomainAll()
|
||||
{
|
||||
string domainPath = $"{Application.dataPath}/Art";
|
||||
string[] domains;
|
||||
// 新增目录获取代码
|
||||
if (Directory.Exists(domainPath))
|
||||
{
|
||||
var dirInfo = new DirectoryInfo(domainPath);
|
||||
// 获取直接子目录(不递归)
|
||||
domains = dirInfo.GetDirectories("*", SearchOption.TopDirectoryOnly)
|
||||
.Select(d => d.Name)
|
||||
.ToArray();
|
||||
}
|
||||
else
|
||||
{
|
||||
domains = Array.Empty<string>();
|
||||
}
|
||||
|
||||
List<CreatArtDomainEntity> domainList = new List<CreatArtDomainEntity>();
|
||||
foreach (var item in domains)
|
||||
{
|
||||
if (Directory.Exists($"{domainPath}/{item}"))
|
||||
{
|
||||
CreatArtDomainEntity domainEntity = new CreatArtDomainEntity(domainList)
|
||||
{
|
||||
DomainName = item,
|
||||
domainPath = $"{domainPath}/{item}"
|
||||
};
|
||||
domainList.Add(domainEntity);
|
||||
}
|
||||
}
|
||||
|
||||
return domainList;
|
||||
}
|
||||
|
||||
private void SetUseTypeData()
|
||||
{
|
||||
if (useType == UseType.Member)
|
||||
{
|
||||
_titleGroupName = "创建成员";
|
||||
}
|
||||
else if (useType == UseType.Project)
|
||||
{
|
||||
_titleGroupName = "创建项目Art";
|
||||
}
|
||||
}
|
||||
|
||||
private bool IsMember()
|
||||
{
|
||||
return useType == UseType.Member;
|
||||
}
|
||||
|
||||
private bool IsProject()
|
||||
{
|
||||
return useType == UseType.Project;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 使用类型
|
||||
/// </summary>
|
||||
public enum UseType
|
||||
{
|
||||
/// <summary>
|
||||
/// 成员使用
|
||||
/// </summary>
|
||||
Member,
|
||||
|
||||
/// <summary>
|
||||
/// 项目使用
|
||||
/// </summary>
|
||||
Project
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user