111
This commit is contained in:
@@ -31,7 +31,7 @@ namespace Stary.Evo.Editor
|
||||
/// </summary>
|
||||
public static List<CreatArtDomainEntity> GetLocalDomainAll()
|
||||
{
|
||||
string domainPath = $"{Application.dataPath}/Art";
|
||||
string domainPath = $"{Application.dataPath}/Member";
|
||||
string[] domains;
|
||||
// 新增目录获取代码
|
||||
if (Directory.Exists(domainPath))
|
||||
@@ -50,7 +50,7 @@ namespace Stary.Evo.Editor
|
||||
List<CreatArtDomainEntity> domainList = new List<CreatArtDomainEntity>();
|
||||
foreach (var item in domains)
|
||||
{
|
||||
if (File.Exists($"{domainPath}/{item}/Scenes/TestScene.unity"))
|
||||
if (File.Exists($"{domainPath}/{item}/Config/ArtSceneData.asset"))
|
||||
{
|
||||
CreatArtDomainEntity domainEntity = new CreatArtDomainEntity(domainList)
|
||||
{
|
||||
|
||||
@@ -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
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -30,7 +30,6 @@ namespace Stary.Evo.Editor
|
||||
[MenuItem("Evo/Art/Art资源打包工具", false, 1)]
|
||||
static void ShowWindows()
|
||||
{
|
||||
|
||||
window = (BuildArtAssetWindow)EditorWindow.GetWindow(typeof(BuildArtAssetWindow));
|
||||
window.Show();
|
||||
}
|
||||
@@ -96,12 +95,10 @@ namespace Stary.Evo.Editor
|
||||
|
||||
#region BuildAssetLogin
|
||||
|
||||
[ShowIf("@ buildAssetType== Stary.Evo.BuildOriginality.BuildAssetType.Login")]
|
||||
[BoxGroup("Login", showLabel: false)]
|
||||
[OnValueChanged("SetWebRequestInfo")]
|
||||
[ShowIf("IsLogin")] [BoxGroup("Login", showLabel: false)] [OnValueChanged("SetWebRequestInfo")]
|
||||
public string ip, userName, password;
|
||||
|
||||
[ShowIf("@ buildAssetType== Stary.Evo.BuildOriginality.BuildAssetType.Login")]
|
||||
[ShowIf("IsLogin")]
|
||||
[BoxGroup("Login", showLabel: false)]
|
||||
[Button("登录", ButtonSizes.Large)]
|
||||
[InfoBox("@ message", InfoMessageType.Info)]
|
||||
@@ -156,7 +153,7 @@ namespace Stary.Evo.Editor
|
||||
}
|
||||
|
||||
[BoxGroup("Build", showLabel: false)]
|
||||
[ShowIf("@ buildAssetType== Stary.Evo.BuildOriginality.BuildAssetType.Build")]
|
||||
[ShowIf("IsBuild")]
|
||||
[Title("包裹列表", titleAlignment: TitleAlignments.Centered)]
|
||||
[HorizontalGroup("Build/BuildPipeline"), HideLabel]
|
||||
[ValueDropdown("GetBuildPackageNames")]
|
||||
@@ -164,7 +161,7 @@ namespace Stary.Evo.Editor
|
||||
public string selectedPackageNames;
|
||||
|
||||
[BoxGroup("Build", showLabel: false)]
|
||||
[ShowIf("@ buildAssetType== Stary.Evo.BuildOriginality.BuildAssetType.Build")]
|
||||
[ShowIf("IsBuild")]
|
||||
[Title("当前打包平台", titleAlignment: TitleAlignments.Centered)]
|
||||
[ReadOnly]
|
||||
[HorizontalGroup("Build/BuildPipeline"), HideLabel]
|
||||
@@ -175,7 +172,7 @@ namespace Stary.Evo.Editor
|
||||
|
||||
[Title("版本号", titleAlignment: TitleAlignments.Centered)]
|
||||
[HorizontalGroup("Build/PackageVersion"), HideLabel]
|
||||
[ShowIf("@ buildAssetType== Stary.Evo.BuildOriginality.BuildAssetType.Build")]
|
||||
[ShowIf("IsBuild")]
|
||||
[OnValueChanged("OnPackageValueChanged")]
|
||||
public string _packageVersion;
|
||||
|
||||
@@ -253,13 +250,13 @@ namespace Stary.Evo.Editor
|
||||
#region Update
|
||||
|
||||
[BoxGroup("Build", showLabel: false)]
|
||||
[ShowIf("@ buildAssetType== Stary.Evo.BuildOriginality.BuildAssetType.Build")]
|
||||
[ShowIf("IsBuild")]
|
||||
[Title("打包本地资源", titleAlignment: TitleAlignments.Centered)]
|
||||
[HideLabel]
|
||||
public BuildAssetEntity onBuildPipelineEntity;
|
||||
|
||||
[BoxGroup("Build", showLabel: false)]
|
||||
[ShowIf("@ buildAssetType== Stary.Evo.BuildOriginality.BuildAssetType.Build")]
|
||||
[ShowIf("IsBuild")]
|
||||
[Title("上传资源", titleAlignment: TitleAlignments.Centered)]
|
||||
[HideLabel]
|
||||
public BuildAssetEntity onUpdateBuildPipelineEntity;
|
||||
@@ -428,9 +425,8 @@ namespace Stary.Evo.Editor
|
||||
EditorUtility.ClearProgressBar();
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
} else if (resResultMessage.code == 200)
|
||||
}
|
||||
else if (resResultMessage.code == 200)
|
||||
|
||||
{
|
||||
EditorUtility.DisplayDialog("提示",
|
||||
@@ -518,5 +514,15 @@ namespace Stary.Evo.Editor
|
||||
onBuildPipelineEntity.SetButtonName($"打包资源包【版本:{_packageVersion}】");
|
||||
onUpdateBuildPipelineEntity.SetButtonName($"更新至服务器【版本:{_packageVersion}】");
|
||||
}
|
||||
|
||||
private bool IsLogin()
|
||||
{
|
||||
return buildAssetType == Stary.Evo.BuildOriginality.BuildAssetType.Login;
|
||||
}
|
||||
|
||||
private bool IsBuild()
|
||||
{
|
||||
return buildAssetType == Stary.Evo.BuildOriginality.BuildAssetType.Build;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -33,7 +33,14 @@ namespace Stary.Evo.Editor
|
||||
bool isOk = EditorUtility.DisplayDialog("提示", "是否检索并创建缺失目录", "是", "否");
|
||||
if (isOk)
|
||||
{
|
||||
ArtServerManageWindow.CreateDomainDirectory(DomainName);
|
||||
// 获取或创建ArtServerManageWindow面板
|
||||
ArtServerManageWindow window = EditorWindow.GetWindow<ArtServerManageWindow>();
|
||||
if (window != null)
|
||||
{
|
||||
window.CreateDomainDirectory(DomainName);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
[HorizontalGroup(Width = 60)]
|
||||
@@ -50,7 +57,7 @@ namespace Stary.Evo.Editor
|
||||
{
|
||||
BuildArtAssetWindow.RemoveBuildAssetWindow();
|
||||
EditorFrameworkUtils.DeleteAllChild(domainPath, FileAttributes.Normal);
|
||||
domainList.Clear();
|
||||
domainList.Remove(this);
|
||||
AssetDatabase.Refresh();
|
||||
|
||||
AssetDatabase.SaveAssets();
|
||||
|
||||
@@ -10,11 +10,11 @@ using UnityEngine;
|
||||
namespace Stary.Evo.Editor
|
||||
{
|
||||
[Serializable]
|
||||
public class CreatArtServerDomainEntity
|
||||
public class CreatMemberServerDomainEntity
|
||||
{
|
||||
private string ip;
|
||||
|
||||
private List<CreatArtServerDomainEntity> domainList;
|
||||
private List<CreatMemberServerDomainEntity> domainList;
|
||||
|
||||
[HorizontalGroup] [ReadOnly] public string DomainName;
|
||||
|
||||
@@ -29,7 +29,7 @@ namespace Stary.Evo.Editor
|
||||
[InlineEditor(InlineEditorObjectFieldModes.CompletelyHidden)]
|
||||
[HideLabel]
|
||||
public ArtSceneData artSceneData;
|
||||
public CreatArtServerDomainEntity(List<CreatArtServerDomainEntity> domainList)
|
||||
public CreatMemberServerDomainEntity(List<CreatMemberServerDomainEntity> domainList)
|
||||
{
|
||||
this.domainList = domainList;
|
||||
}
|
||||
@@ -50,7 +50,7 @@ namespace Stary.Evo.Editor
|
||||
_endableBtnColor = Color.red;
|
||||
}
|
||||
string artSceneDataPath =
|
||||
$"Assets/Art/{domainName}/Config/ArtSceneData.asset";
|
||||
$"Assets/Member/{domainName}/Config/ArtSceneData.asset";
|
||||
ArtSceneData artSceneData =
|
||||
AssetDatabase.LoadAssetAtPath<ArtSceneData>(artSceneDataPath);
|
||||
if (artSceneData != null)
|
||||
@@ -75,7 +75,11 @@ namespace Stary.Evo.Editor
|
||||
bool isOk = EditorUtility.DisplayDialog("提示", "是否检索并创建缺失目录", "是", "否");
|
||||
if (isOk)
|
||||
{
|
||||
ArtServerManageWindow.CreateDomainDirectory(DomainName);
|
||||
ArtServerManageWindow window = EditorWindow.GetWindow<ArtServerManageWindow>();
|
||||
if (window != null)
|
||||
{
|
||||
window.CreateDomainDirectory(DomainName);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
|
||||
using UnityEditor;
|
||||
using UnityEditor.U2D;
|
||||
using UnityEngine;
|
||||
@@ -16,28 +15,123 @@ namespace Stary.Evo.Editor
|
||||
private static string _packageName;
|
||||
|
||||
|
||||
public static string ArtRoot
|
||||
public static string AbsoluteMemberRoot
|
||||
{
|
||||
get { return Application.dataPath + "/Art"; }
|
||||
get { return Application.dataPath + "/Member"; }
|
||||
}
|
||||
|
||||
public static string RelativeMemberRoot
|
||||
{
|
||||
get { return "Assets/Member"; }
|
||||
}
|
||||
|
||||
public static void CopyArtScenes()
|
||||
{
|
||||
List<ArtScene> artScenes = new List<ArtScene>();
|
||||
string artSceneDataPath =
|
||||
$"Assets/Member/{_packageName}/Config/ArtSceneData.asset";
|
||||
ArtSceneData artSceneData =
|
||||
AssetDatabase.LoadAssetAtPath<ArtSceneData>(artSceneDataPath);
|
||||
if (artSceneData != null)
|
||||
{
|
||||
artScenes = artSceneData.artScenes;
|
||||
foreach (var artScene in artSceneData.artScenes)
|
||||
{
|
||||
artScene.LoadScenePath();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Debug.LogError($"UnityEvo:ArtSceneData不存在,无法打包,请检查路径{artSceneDataPath}");
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
string destPath = $"{AbsoluteMemberRoot}/{_packageName}/Scenes";
|
||||
if (Directory.Exists(destPath))
|
||||
{
|
||||
Directory.Delete(destPath, true);
|
||||
}
|
||||
|
||||
Directory.CreateDirectory(destPath);
|
||||
|
||||
foreach (var artScene in artScenes)
|
||||
{
|
||||
string scenePath = artScene.scenePath;
|
||||
bool success = CopyUnityAsset(scenePath,
|
||||
$"{RelativeMemberRoot}/{_packageName}/Scenes/{artScene.sceneAsset.name}.unity");
|
||||
|
||||
if (success)
|
||||
{
|
||||
Debug.Log("场景复制成功!");
|
||||
}
|
||||
|
||||
// string destScenePath = $"{destPath}/{artScene.sceneAsset.name}.unity";
|
||||
// File.Copy(sceneAsset.path, destScenePath, true);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 拷贝Unity资源文件(推荐方法)
|
||||
/// </summary>
|
||||
/// <param name="sourcePath">源文件在Assets下的相对路径</param>
|
||||
/// <param name="destPath">目标文件在Assets下的相对路径</param>
|
||||
/// <returns>是否拷贝成功</returns>
|
||||
public static bool CopyUnityAsset(string sourcePath, string destPath)
|
||||
{
|
||||
if (string.IsNullOrEmpty(sourcePath) || string.IsNullOrEmpty(destPath))
|
||||
{
|
||||
Debug.LogError("源路径或目标路径为空!");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!AssetDatabase.IsValidFolder(System.IO.Path.GetDirectoryName(destPath)))
|
||||
{
|
||||
Debug.LogError($"目标目录不存在: {System.IO.Path.GetDirectoryName(destPath)}");
|
||||
return false;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
// 使用AssetDatabase拷贝资源
|
||||
bool result = AssetDatabase.CopyAsset(sourcePath, destPath);
|
||||
if (!result)
|
||||
{
|
||||
Debug.LogError($"拷贝失败: {sourcePath} -> {destPath}");
|
||||
return false;
|
||||
}
|
||||
|
||||
Debug.Log($"成功拷贝资源: {sourcePath} -> {destPath}");
|
||||
AssetDatabase.Refresh(); // 刷新资源数据库
|
||||
return true;
|
||||
}
|
||||
catch (System.Exception e)
|
||||
{
|
||||
Debug.LogError($"拷贝资源时出错: {e.Message}");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public static void AddArtMark(Action complete)
|
||||
{
|
||||
_packageName = BuildArtAssetWindow.GetBuildPackageName();
|
||||
CopyArtScenes();
|
||||
AssetBundleCollectorPackage assetBundleCollectorPackage = null;
|
||||
foreach (var package in AssetBundleCollectorSettingData.Setting.Packages)
|
||||
{
|
||||
if (package.PackageName ==_packageName)
|
||||
if (package.PackageName == _packageName)
|
||||
{
|
||||
assetBundleCollectorPackage = package;
|
||||
}
|
||||
}
|
||||
|
||||
if (assetBundleCollectorPackage != null)
|
||||
{
|
||||
YooAsset.Editor.AssetBundleCollectorSettingData.RemovePackage(assetBundleCollectorPackage);
|
||||
}
|
||||
|
||||
MarkArt();
|
||||
CollectSVC(ArtRoot, _packageName,complete);
|
||||
CollectSVC(AbsoluteMemberRoot, _packageName, complete);
|
||||
}
|
||||
|
||||
|
||||
@@ -53,7 +147,7 @@ namespace Stary.Evo.Editor
|
||||
addressDic.Clear();
|
||||
collectorGroupDic.Clear();
|
||||
///创建分组
|
||||
string remotedRoot = $"{ArtRoot}/{_packageName}";
|
||||
string remotedRoot = $"{AbsoluteMemberRoot}/{_packageName}";
|
||||
DirectoryInfo[] dirs = new DirectoryInfo(remotedRoot).GetDirectories();
|
||||
|
||||
var setting = YooAsset.Editor.AssetBundleCollectorSettingData.Setting;
|
||||
@@ -74,7 +168,7 @@ namespace Stary.Evo.Editor
|
||||
{
|
||||
string groupName = info.Name;
|
||||
|
||||
if (info.Name == "Scenes"||info.Name == "Config")
|
||||
if (info.Name == "Scenes" || info.Name == "Config")
|
||||
{
|
||||
AssetBundleCollectorGroup collectorGroup =
|
||||
YooAsset.Editor.AssetBundleCollectorSettingData.CreateGroup(package, groupName);
|
||||
@@ -87,9 +181,11 @@ namespace Stary.Evo.Editor
|
||||
{
|
||||
Debug.LogError("分组 : " + groupName + "已存在,请检查资源目录,避免重复");
|
||||
}
|
||||
|
||||
AutoMarkRootAddress(info);
|
||||
}
|
||||
}
|
||||
|
||||
// AssetDatabase.SaveAssets();
|
||||
// AssetDatabase.Refresh();
|
||||
MarkStatus();
|
||||
@@ -165,120 +261,6 @@ namespace Stary.Evo.Editor
|
||||
}
|
||||
}
|
||||
|
||||
#region 图集
|
||||
|
||||
public static void AutoCreateSpriteAtlas(string domainRootRes)
|
||||
{
|
||||
string AtlasRemotedRoot = domainRootRes + "/SpriteAtlas";
|
||||
string SpriteRemotedAtlas = domainRootRes + "/Sprites";
|
||||
DirectoryInfo[] remotedirs = new DirectoryInfo(SpriteRemotedAtlas).GetDirectories();
|
||||
foreach (var info in remotedirs)
|
||||
{
|
||||
AddSpriteAtlas(SpriteRemotedAtlas + "/" + info.Name, SpriteRemotedAtlas,
|
||||
AtlasRemotedRoot, info);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 自动创建图集
|
||||
/// </summary>
|
||||
/// <param name="path">路径</param>
|
||||
/// <param name="dir">文件夹</param>
|
||||
private static void AddSpriteAtlas(string path, string atlasRoot, string spriteAtlas, DirectoryInfo dir)
|
||||
{
|
||||
var groupname = "SpriteAtlas";
|
||||
var dirs = dir.GetDirectories();
|
||||
if (dirs == null || dirs.Length == 0)
|
||||
{
|
||||
string name = path.Replace(atlasRoot + "/", string.Empty).Replace("/", "_");
|
||||
string filePath = $"{spriteAtlas}/{name}.spriteatlas";
|
||||
// string[] dirSplit =
|
||||
// filePath.Split(new string[] { $"AddressableRes/{Path.GetFileName(spriteAtlas)}" },
|
||||
// StringSplitOptions.RemoveEmptyEntries);
|
||||
// string address = (dirSplit[dirSplit.Length - 1]).Substring(1).Replace("\\", "/");
|
||||
// Debug.Log("spriteatlasaddress:" + address);
|
||||
int assetIndex = filePath.IndexOf("Assets");
|
||||
string guidPath = filePath.Remove(0, assetIndex);
|
||||
if (!File.Exists(filePath))
|
||||
{
|
||||
SpriteAtlas atlas = new SpriteAtlas();
|
||||
//设置打包参数
|
||||
SpriteAtlasPackingSettings packSetting = new SpriteAtlasPackingSettings()
|
||||
{
|
||||
blockOffset = 1,
|
||||
enableRotation = true,
|
||||
enableTightPacking = false,
|
||||
padding = 2,
|
||||
};
|
||||
atlas.SetPackingSettings(packSetting);
|
||||
|
||||
//设置打包后Texture图集信息
|
||||
SpriteAtlasTextureSettings textureSettings = new SpriteAtlasTextureSettings()
|
||||
{
|
||||
readable = false,
|
||||
generateMipMaps = false,
|
||||
sRGB = true,
|
||||
filterMode = FilterMode.Bilinear,
|
||||
};
|
||||
atlas.SetTextureSettings(textureSettings);
|
||||
|
||||
//设置平台图集大小压缩等信息
|
||||
TextureImporterPlatformSettings platformSettings = new TextureImporterPlatformSettings()
|
||||
{
|
||||
maxTextureSize = 4096,
|
||||
format = TextureImporterFormat.Automatic,
|
||||
crunchedCompression = true,
|
||||
textureCompression = TextureImporterCompression.Compressed,
|
||||
compressionQuality = 50,
|
||||
};
|
||||
atlas.SetPlatformSettings(platformSettings);
|
||||
AssetDatabase.CreateAsset(atlas, guidPath);
|
||||
int pathIndex = path.IndexOf("Assets");
|
||||
string spritePath = path.Remove(0, pathIndex);
|
||||
UnityEngine.Object obj = AssetDatabase.LoadAssetAtPath(spritePath, typeof(UnityEngine.Object));
|
||||
atlas.Add(new[] { obj });
|
||||
AssetDatabase.SaveAssets();
|
||||
AssetDatabase.Refresh();
|
||||
}
|
||||
|
||||
var guid = AssetDatabase.AssetPathToGUID(guidPath);
|
||||
|
||||
var group = collectorGroupDic[groupname];
|
||||
if (group != null)
|
||||
{
|
||||
AssetBundleCollector collector = new AssetBundleCollector()
|
||||
{
|
||||
CollectPath = guidPath,
|
||||
CollectorGUID = guid,
|
||||
CollectorType = ECollectorType.MainAssetCollector,
|
||||
AddressRuleName = nameof(AddressByFolderAndFileName),
|
||||
AssetTags = groupname,
|
||||
};
|
||||
YooAsset.Editor.AssetBundleCollectorSettingData.CreateCollector(group, collector);
|
||||
|
||||
|
||||
AddAddressInfo(path, GetAssetAddress(path));
|
||||
}
|
||||
else
|
||||
{
|
||||
Debug.LogError("分组 = " + GetAssetAddress(path) + "不存在");
|
||||
}
|
||||
|
||||
AssetDatabase.Refresh();
|
||||
}
|
||||
else
|
||||
{
|
||||
if (dirs.Length > 0)
|
||||
{
|
||||
foreach (var info in dirs)
|
||||
{
|
||||
AddSpriteAtlas(path + "/" + info.Name, atlasRoot, spriteAtlas, info);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private static void AddAddressInfo(string assetPath, string address)
|
||||
{
|
||||
@@ -326,7 +308,7 @@ namespace Stary.Evo.Editor
|
||||
}
|
||||
}
|
||||
|
||||
public static void CollectSVC(string root,string packageName,Action complete)
|
||||
public static void CollectSVC(string root, string packageName, Action complete)
|
||||
{
|
||||
string remotedRoot = $"{root}/{packageName}/ShaderVariants";
|
||||
string remotedRootFileName = $"{remotedRoot}/{packageName}.shadervariants";
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "com.staryevo.buildoriginality",
|
||||
"version": "1.0.5",
|
||||
"version": "1.0.6",
|
||||
"displayName": "00.StaryEvo.BuildOriginality",
|
||||
"description": "美术打包工具",
|
||||
"unity": "2021.3",
|
||||
|
||||
@@ -31,7 +31,7 @@ namespace Stary.Evo.Editor
|
||||
public static OdinEditorWindow window;
|
||||
private HotfixMainResDomain hotfixMainResDomain;
|
||||
|
||||
[MenuItem("Evo/Dev/资源打包工具",false, 2)]
|
||||
[MenuItem("Evo/Dev/资源打包工具", false, 2)]
|
||||
static void ShowWindows()
|
||||
{
|
||||
#if NotUpdate
|
||||
@@ -71,10 +71,11 @@ namespace Stary.Evo.Editor
|
||||
else
|
||||
{
|
||||
ip = hotfixMainResDomain.hotfixMainResDomainEntity.ipconfig;
|
||||
EditorPrefs.SetString("ip",ip);
|
||||
EditorPrefs.SetString("ip", ip);
|
||||
userName = hotfixMainResDomain.hotfixMainResDomainEntity.username;
|
||||
password = hotfixMainResDomain.hotfixMainResDomainEntity.password;
|
||||
}
|
||||
|
||||
GetBuildPackageNames();
|
||||
if (string.IsNullOrEmpty(ip))
|
||||
{
|
||||
@@ -103,12 +104,10 @@ namespace Stary.Evo.Editor
|
||||
|
||||
#region BuildAssetLogin
|
||||
|
||||
[ShowIf("@ buildAssetType== Stary.Evo.BuildAssetType.Login")]
|
||||
[BoxGroup("Login", showLabel: false)]
|
||||
[OnValueChanged("SetWebRequestInfo")]
|
||||
[ShowIf("IsLogin")] [BoxGroup("Login", showLabel: false)] [OnValueChanged("SetWebRequestInfo")]
|
||||
public string ip, userName, password;
|
||||
|
||||
[ShowIf("@ buildAssetType== Stary.Evo.BuildAssetType.Login")]
|
||||
[ShowIf("IsLogin")]
|
||||
[BoxGroup("Login", showLabel: false)]
|
||||
[Button("登录", ButtonSizes.Large)]
|
||||
[InfoBox("@ message", InfoMessageType.Info)]
|
||||
@@ -129,6 +128,8 @@ namespace Stary.Evo.Editor
|
||||
UpdateMessage(islogin);
|
||||
}
|
||||
|
||||
|
||||
|
||||
private void SetWebRequestInfo()
|
||||
{
|
||||
if (hotfixMainResDomain != null)
|
||||
@@ -136,7 +137,7 @@ namespace Stary.Evo.Editor
|
||||
hotfixMainResDomain.hotfixMainResDomainEntity.ipconfig = ip;
|
||||
hotfixMainResDomain.hotfixMainResDomainEntity.username = userName;
|
||||
hotfixMainResDomain.hotfixMainResDomainEntity.password = password;
|
||||
EditorPrefs.SetString("ip",ip);
|
||||
EditorPrefs.SetString("ip", ip);
|
||||
EditorUtility.SetDirty(hotfixMainResDomain);
|
||||
AssetDatabase.SaveAssets();
|
||||
}
|
||||
@@ -163,7 +164,7 @@ namespace Stary.Evo.Editor
|
||||
}
|
||||
|
||||
[BoxGroup("Build", showLabel: false)]
|
||||
[ShowIf("@ buildAssetType== Stary.Evo.BuildAssetType.Build")]
|
||||
[ShowIf("IsBuild")]
|
||||
[Title("包裹列表", titleAlignment: TitleAlignments.Centered)]
|
||||
[HorizontalGroup("Build/BuildPipeline"), HideLabel]
|
||||
[ValueDropdown("GetBuildPackageNames")]
|
||||
@@ -171,7 +172,7 @@ namespace Stary.Evo.Editor
|
||||
public string selectedPackageNames;
|
||||
|
||||
[BoxGroup("Build", showLabel: false)]
|
||||
[ShowIf("@ buildAssetType== Stary.Evo.BuildAssetType.Build")]
|
||||
[ShowIf("IsBuild")]
|
||||
[Title("当前打包平台", titleAlignment: TitleAlignments.Centered)]
|
||||
[ReadOnly]
|
||||
[HorizontalGroup("Build/BuildPipeline"), HideLabel]
|
||||
@@ -200,7 +201,7 @@ namespace Stary.Evo.Editor
|
||||
#region MarkAsset
|
||||
|
||||
[BoxGroup("Build", showLabel: false)]
|
||||
[ShowIf("@ buildAssetType== Stary.Evo.BuildAssetType.Build")]
|
||||
[ShowIf("IsBuild")]
|
||||
[Title("标记资源", titleAlignment: TitleAlignments.Centered)]
|
||||
[HorizontalGroup("Build/HyBridClrBuildEntity"), HideLabel]
|
||||
public BuildAssetEntity markAssetEntity =
|
||||
@@ -211,7 +212,7 @@ namespace Stary.Evo.Editor
|
||||
#region BuildAsset
|
||||
|
||||
[BoxGroup("Build", showLabel: false)]
|
||||
[ShowIf("@ buildAssetType== Stary.Evo.BuildAssetType.Build")]
|
||||
[ShowIf("IsBuild")]
|
||||
[InlineEditor(InlineEditorObjectFieldModes.CompletelyHidden)]
|
||||
[HideLabel]
|
||||
public BuildAssetDataSetting BuildAssetDataSetting;
|
||||
@@ -292,7 +293,7 @@ namespace Stary.Evo.Editor
|
||||
#region Update
|
||||
|
||||
[BoxGroup("Build", showLabel: false)]
|
||||
[ShowIf("@ buildAssetType== Stary.Evo.BuildAssetType.Build")]
|
||||
[ShowIf("IsBuild")]
|
||||
[Title("打包本地资源", titleAlignment: TitleAlignments.Centered)]
|
||||
[HideLabel]
|
||||
public BuildAssetEntity onBuildPipelineEntity;
|
||||
@@ -300,8 +301,7 @@ namespace Stary.Evo.Editor
|
||||
[BoxGroup("Build", showLabel: false)]
|
||||
[Title("上传资源", titleAlignment: TitleAlignments.Centered)]
|
||||
[HideLabel]
|
||||
[ShowIf(
|
||||
"@ BuildAssetDataSetting.environmentType== EnvironmentType.Release && buildAssetType== Stary.Evo.BuildAssetType.Build")]
|
||||
[ShowIf("@ IsRelease() && IsBuild()")]
|
||||
public BuildAssetEntity onUpdateBuildPipelineEntity;
|
||||
|
||||
|
||||
@@ -405,7 +405,7 @@ namespace Stary.Evo.Editor
|
||||
// 假设 BuildinCatalog 文件名为 BuildinCatalog.json
|
||||
|
||||
string sourcePath = Path.Combine(copyPackageDirectory, fileName); // 源文件路径
|
||||
string destinationPath = Path.Combine(outFilePath, fileName); // 目标文件路径
|
||||
string destinationPath = Path.Combine(outFilePath, fileName); // 目标文件路径
|
||||
|
||||
// 如果目标文件已存在,则覆盖
|
||||
if (File.Exists(destinationPath))
|
||||
@@ -415,7 +415,6 @@ namespace Stary.Evo.Editor
|
||||
|
||||
// 执行拷贝操作
|
||||
File.Copy(sourcePath, destinationPath);
|
||||
|
||||
}
|
||||
|
||||
public static async Task UpdateFileDataResDomain(BuildAssetDataSetting setting, string zipFilePath)
|
||||
@@ -556,8 +555,24 @@ namespace Stary.Evo.Editor
|
||||
onBuildPipelineEntity.SetButtonName($"打包资源包【版本:{BuildAssetDataSetting.packageVersion}】");
|
||||
onUpdateBuildPipelineEntity.SetButtonName($"更新至服务器【版本:{BuildAssetDataSetting.packageVersion}】");
|
||||
}
|
||||
private bool IsLogin()
|
||||
{
|
||||
return buildAssetType == BuildAssetType.Login;
|
||||
}
|
||||
|
||||
private bool IsBuild()
|
||||
{
|
||||
return buildAssetType == BuildAssetType.Build;
|
||||
}
|
||||
|
||||
private bool IsRelease()
|
||||
{
|
||||
return BuildAssetDataSetting.environmentType == EnvironmentType.Release;
|
||||
}
|
||||
|
||||
private bool IsDebug()
|
||||
{
|
||||
return BuildAssetDataSetting.environmentType == EnvironmentType.Debug;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
3
Assets/00.StaryEvoTools/Editor/OdinDrawerAttribute.meta
Normal file
3
Assets/00.StaryEvoTools/Editor/OdinDrawerAttribute.meta
Normal file
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 443e7176dc1c439ab6d9ffbf3e38a2c7
|
||||
timeCreated: 1762222048
|
||||
@@ -0,0 +1,7 @@
|
||||
namespace Stary.Evo.OdinDrawerAttribute
|
||||
{
|
||||
public class OdinDrawerAttribute
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: dfa0ecbdc2e043ec87148405e329a5cd
|
||||
timeCreated: 1762222058
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "com.staryevo.tools",
|
||||
"version": "1.1.18",
|
||||
"version": "1.1.19",
|
||||
"displayName": "00.StaryEvo.Tools",
|
||||
"description": "This is an Framework package(后台服务器版本,端口9527)",
|
||||
"unity": "2021.3",
|
||||
|
||||
Reference in New Issue
Block a user