【m】框架大更新
This commit is contained in:
@@ -0,0 +1,182 @@
|
||||
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using Sirenix.OdinInspector;
|
||||
using Sirenix.OdinInspector.Editor;
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Stary.Evo.Editor
|
||||
{
|
||||
public class ArtServerManageWindow : OdinEditorWindow
|
||||
{
|
||||
|
||||
[MenuItem("Evo/Art/服务器数据管理工具", false, 2)]
|
||||
static void Init()
|
||||
{
|
||||
// Get existing open window or if none, make a new one:
|
||||
ArtServerManageWindow window = (ArtServerManageWindow)EditorWindow.GetWindow(typeof(ArtServerManageWindow));
|
||||
window.Show();
|
||||
}
|
||||
|
||||
[TitleGroup("创建Art作用域")] public string domain;
|
||||
|
||||
[TitleGroup("创建Art作用域")]
|
||||
[Button("创建Art", ButtonSizes.Large)]
|
||||
public async void CreatDomain()
|
||||
{
|
||||
// if (GetCreatDomainAll().Count>0)
|
||||
// {
|
||||
// EditorUtility.DisplayDialog("错误!", "Domain仅可以创建一个,请在下方删除存在的Domain", "确定");
|
||||
// return;
|
||||
// }
|
||||
|
||||
if (string.IsNullOrEmpty(domain))
|
||||
{
|
||||
EditorUtility.DisplayDialog("错误!", "请输入将要创建Art的编号", "确定");
|
||||
return;
|
||||
}
|
||||
|
||||
string artDomainPath = $"{Application.dataPath}/Art/{domain}";
|
||||
if (!Directory.Exists(artDomainPath))
|
||||
{
|
||||
Directory.CreateDirectory(artDomainPath);
|
||||
|
||||
if (!Directory.Exists(artDomainPath))
|
||||
//创建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");
|
||||
//创建Shader文件夹
|
||||
CreatDirectory(artDomainPath + "/Shader");
|
||||
//创建Textures文件夹
|
||||
CreatDirectory(artDomainPath + "/Textures");
|
||||
|
||||
//创建Config文件夹
|
||||
CreatDirectory(artDomainPath + "/Config");
|
||||
|
||||
File.WriteAllTextAsync(
|
||||
$"{artDomainPath}/这里放所有美术的资源,因涉及打包依赖等原因,不建议在上一层节点新增文件夹,如涉及文件夹规范等问题请@张铮.hint", "");
|
||||
}
|
||||
|
||||
//创建Art 测试场景
|
||||
/* 2. 再建 Scenes/Test */
|
||||
string sceneDir = $"{artDomainPath}/Scenes";
|
||||
if (!Directory.Exists(sceneDir))
|
||||
{
|
||||
Directory.CreateDirectory(sceneDir);
|
||||
}
|
||||
/* 3. 创建新场景 */
|
||||
var newScene = UnityEditor.SceneManagement.EditorSceneManager.NewScene(
|
||||
UnityEditor.SceneManagement.NewSceneSetup.DefaultGameObjects,
|
||||
UnityEditor.SceneManagement.NewSceneMode.Single);
|
||||
|
||||
/* 4. 删除默认相机(和灯光)*/
|
||||
foreach (var go in newScene.GetRootGameObjects())
|
||||
{
|
||||
if (go.name == "Main Camera" || go.name == "Directional Light")
|
||||
GameObject.DestroyImmediate(go);
|
||||
}
|
||||
|
||||
/* 5. 载入并实例化 RKCameraRig.prefab */
|
||||
string prefabPath = "Prefabs/BaseSetting/RKCameraRig";
|
||||
|
||||
var prefab = Resources.Load<GameObject>(prefabPath);
|
||||
var spawned = (GameObject)PrefabUtility.InstantiatePrefab(prefab);
|
||||
spawned.name = "RKCameraRigTest";
|
||||
|
||||
/* 6. 保存场景 */
|
||||
string scenePath = Path.Combine("Assets/Art", domain, "Scenes", "TestScene.unity");
|
||||
UnityEditor.SceneManagement.EditorSceneManager.SaveScene(newScene, scenePath);
|
||||
//创建Art 测试场景配置文件
|
||||
string configDir = $"{artDomainPath}/Config";
|
||||
if (!Directory.Exists(configDir))
|
||||
{
|
||||
Directory.CreateDirectory(configDir);
|
||||
}
|
||||
//模块配置资源
|
||||
ArtSceneData artSceneData = CreateInstance<ArtSceneData>();
|
||||
|
||||
|
||||
AssetDatabase.CreateAsset(artSceneData, $"Assets/Art/{domain}/Config/ArtSceneData.asset");
|
||||
|
||||
AssetDatabase.SaveAssets();
|
||||
AssetDatabase.Refresh();
|
||||
}
|
||||
|
||||
|
||||
[ListDrawerSettings(DraggableItems = false, ShowFoldout = false, ShowPaging = false, ShowItemCount = false,
|
||||
HideRemoveButton = true, HideAddButton = true)]
|
||||
public List<CreatArtServerDomainEntity> domainList;
|
||||
|
||||
protected override async void Initialize()
|
||||
{
|
||||
base.Initialize();
|
||||
if (domainList != null)
|
||||
domainList.Clear();
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
private static void CreatDirectory(string artDomainPath)
|
||||
{
|
||||
if (!Directory.Exists(artDomainPath))
|
||||
{
|
||||
//创建Animation文件夹
|
||||
Directory.CreateDirectory(artDomainPath);
|
||||
}
|
||||
}
|
||||
public static void CreateDomainDirectory(string domain)
|
||||
{
|
||||
string 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");
|
||||
AssetDatabase.Refresh();
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user