This commit is contained in:
2025-11-04 16:26:50 +08:00
parent 6a73f11f18
commit d2bf1ada3b
13 changed files with 408 additions and 219 deletions

View File

@@ -31,7 +31,7 @@ namespace Stary.Evo.Editor
/// </summary> /// </summary>
public static List<CreatArtDomainEntity> GetLocalDomainAll() public static List<CreatArtDomainEntity> GetLocalDomainAll()
{ {
string domainPath = $"{Application.dataPath}/Art"; string domainPath = $"{Application.dataPath}/Member";
string[] domains; string[] domains;
// 新增目录获取代码 // 新增目录获取代码
if (Directory.Exists(domainPath)) if (Directory.Exists(domainPath))
@@ -50,7 +50,7 @@ namespace Stary.Evo.Editor
List<CreatArtDomainEntity> domainList = new List<CreatArtDomainEntity>(); List<CreatArtDomainEntity> domainList = new List<CreatArtDomainEntity>();
foreach (var item in domains) 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) CreatArtDomainEntity domainEntity = new CreatArtDomainEntity(domainList)
{ {

View File

@@ -1,16 +1,17 @@
using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.IO; using System.IO;
using System.Linq;
using Sirenix.OdinInspector; using Sirenix.OdinInspector;
using Sirenix.OdinInspector.Editor; using Sirenix.OdinInspector.Editor;
using UnityEditor; using UnityEditor;
using UnityEngine; using UnityEngine;
using UnityEngine.Serialization;
namespace Stary.Evo.Editor namespace Stary.Evo.Editor
{ {
public class ArtServerManageWindow : OdinEditorWindow public class ArtServerManageWindow : OdinEditorWindow
{ {
[MenuItem("Evo/Art/服务器数据管理工具", false, 2)] [MenuItem("Evo/Art/服务器数据管理工具", false, 2)]
static void Init() static void Init()
{ {
@@ -19,25 +20,39 @@ namespace Stary.Evo.Editor
window.Show(); window.Show();
} }
[TitleGroup("创建Art作用域")] public string domain; [EnumToggleButtons, HideLabel] [OnValueChanged("SetUseTypeData")]
public UseType useType = UseType.Member;
[TitleGroup("创建Art作用域")] private string _titleGroupName;
[Button("创建Art", ButtonSizes.Large)]
public async void CreatDomain() [TitleGroup("@ _titleGroupName")] public string productName;
[TitleGroup("@ _titleGroupName")]
[Button("@ _titleGroupName", ButtonSizes.Large)]
public void CreatDomain()
{ {
// if (GetCreatDomainAll().Count>0) if (useType == UseType.Member)
// { {
// EditorUtility.DisplayDialog("错误!", "Domain仅可以创建一个请在下方删除存在的Domain", "确定"); CreatMemberFiled();
// return; }
// } else if (useType == UseType.Project)
{
CreatArtFiled();
}
}
if (string.IsNullOrEmpty(domain)) /// <summary>
/// 创建项目目录
/// </summary>
private void CreatArtFiled()
{
if (string.IsNullOrEmpty(productName))
{ {
EditorUtility.DisplayDialog("错误!", "请输入将要创建Art的编号", "确定"); EditorUtility.DisplayDialog("错误!", "请输入将要创建Art的编号", "确定");
return; return;
} }
string artDomainPath = $"{Application.dataPath}/Art/{domain}"; string artDomainPath = $"{Application.dataPath}/Art/{productName}";
if (!Directory.Exists(artDomainPath)) if (!Directory.Exists(artDomainPath))
{ {
Directory.CreateDirectory(artDomainPath); Directory.CreateDirectory(artDomainPath);
@@ -64,9 +79,6 @@ namespace Stary.Evo.Editor
//创建Textures文件夹 //创建Textures文件夹
CreatDirectory(artDomainPath + "/Textures"); CreatDirectory(artDomainPath + "/Textures");
//创建Config文件夹
CreatDirectory(artDomainPath + "/Config");
File.WriteAllTextAsync( File.WriteAllTextAsync(
$"{artDomainPath}/这里放所有美术的资源,因涉及打包依赖等原因,不建议在上一层节点新增文件夹,如涉及文件夹规范等问题请@张铮.hint", ""); $"{artDomainPath}/这里放所有美术的资源,因涉及打包依赖等原因,不建议在上一层节点新增文件夹,如涉及文件夹规范等问题请@张铮.hint", "");
} }
@@ -78,6 +90,7 @@ namespace Stary.Evo.Editor
{ {
Directory.CreateDirectory(sceneDir); Directory.CreateDirectory(sceneDir);
} }
/* 3. 创建新场景 */ /* 3. 创建新场景 */
var newScene = UnityEditor.SceneManagement.EditorSceneManager.NewScene( var newScene = UnityEditor.SceneManagement.EditorSceneManager.NewScene(
UnityEditor.SceneManagement.NewSceneSetup.DefaultGameObjects, UnityEditor.SceneManagement.NewSceneSetup.DefaultGameObjects,
@@ -98,64 +111,135 @@ namespace Stary.Evo.Editor
spawned.name = "RKCameraRigTest"; spawned.name = "RKCameraRigTest";
/* 6. 保存场景 */ /* 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); UnityEditor.SceneManagement.EditorSceneManager.SaveScene(newScene, scenePath);
//创建Art 测试场景配置文件
string configDir = $"{artDomainPath}/Config";
if (!Directory.Exists(configDir))
{
Directory.CreateDirectory(configDir);
} }
/// <summary>
/// 创建成员目录
/// </summary>
private void CreatMemberFiled()
{
if (string.IsNullOrEmpty(productName))
{
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>(); 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.SaveAssets();
AssetDatabase.Refresh(); AssetDatabase.Refresh();
} }
[ShowIf("IsMember")]
[ListDrawerSettings(DraggableItems = false, ShowFoldout = false, ShowPaging = false, ShowItemCount = false, [ListDrawerSettings(DraggableItems = false, ShowFoldout = false, ShowPaging = false, ShowItemCount = false,
HideRemoveButton = true, HideAddButton = true)] 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() protected override async void Initialize()
{ {
base.Initialize(); base.Initialize();
if (domainList != null) SetUseTypeData();
domainList.Clear(); if (domainMemberList != null)
{
domainMemberList.Clear();
}
domainMemberList = new List<CreatMemberServerDomainEntity>();
var resDmainResponse = await ArtLoadAssetServer.GetServerDomainAll(); var resDmainResponse = await ArtLoadAssetServer.GetServerDomainAll();
foreach (var response in resDmainResponse) foreach (var response in resDmainResponse)
{ {
string domainPath = $"{Application.dataPath}/Art/{response.DomainName}"; string domainPath = $"{Application.dataPath}/Member/{response.DomainName}";
var domainEntity = new CreatArtServerDomainEntity(domainList); var domainEntity = new CreatMemberServerDomainEntity(domainMemberList);
domainEntity.SetDomainData(response.DomainName, domainPath,response, ArtLoadAssetServer.ip); domainEntity.SetDomainData(response.DomainName, domainPath, response, ArtLoadAssetServer.ip);
domainList.Add(domainEntity); domainMemberList.Add(domainEntity);
}
} }
artList = GetCreatDomainAll();
}
private static void CreatDirectory(string artDomainPath) private static void CreatDirectory(string artDomainPath)
{ {
if (!Directory.Exists(artDomainPath)) if (!Directory.Exists(artDomainPath))
{ {
//创建Animation文件夹
Directory.CreateDirectory(artDomainPath); 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)) if (!Directory.Exists(artDomainPath))
{ {
EditorUtility.DisplayDialog("提示", $"不存在此Domain:{domain},无法创建", "确定"); EditorUtility.DisplayDialog("提示", $"不存在此Domain:{domain},无法创建", "确定");
return; return;
} }
if (useType == UseType.Member)
{
//创建Config文件夹
CreatDirectory(artDomainPath + "/Config");
//创建Scenes文件夹
CreatDirectory(artDomainPath + "/Scenes");
//创建/Scenes/Test文件夹
CreatDirectory(artDomainPath + "/Scenes/Test");
}
else if (useType == UseType.Project)
{
//创建Animation文件夹 //创建Animation文件夹
CreatDirectory(artDomainPath + "/Animation"); CreatDirectory(artDomainPath + "/Animation");
//创建Effects文件夹 //创建Effects文件夹
@@ -176,7 +260,85 @@ namespace Stary.Evo.Editor
CreatDirectory(artDomainPath + "/Shader"); CreatDirectory(artDomainPath + "/Shader");
//创建Textures文件夹 //创建Textures文件夹
CreatDirectory(artDomainPath + "/Textures"); CreatDirectory(artDomainPath + "/Textures");
}
AssetDatabase.Refresh(); 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
}
} }
} }

View File

@@ -30,7 +30,6 @@ namespace Stary.Evo.Editor
[MenuItem("Evo/Art/Art资源打包工具", false, 1)] [MenuItem("Evo/Art/Art资源打包工具", false, 1)]
static void ShowWindows() static void ShowWindows()
{ {
window = (BuildArtAssetWindow)EditorWindow.GetWindow(typeof(BuildArtAssetWindow)); window = (BuildArtAssetWindow)EditorWindow.GetWindow(typeof(BuildArtAssetWindow));
window.Show(); window.Show();
} }
@@ -96,12 +95,10 @@ namespace Stary.Evo.Editor
#region BuildAssetLogin #region BuildAssetLogin
[ShowIf("@ buildAssetType== Stary.Evo.BuildOriginality.BuildAssetType.Login")] [ShowIf("IsLogin")] [BoxGroup("Login", showLabel: false)] [OnValueChanged("SetWebRequestInfo")]
[BoxGroup("Login", showLabel: false)]
[OnValueChanged("SetWebRequestInfo")]
public string ip, userName, password; public string ip, userName, password;
[ShowIf("@ buildAssetType== Stary.Evo.BuildOriginality.BuildAssetType.Login")] [ShowIf("IsLogin")]
[BoxGroup("Login", showLabel: false)] [BoxGroup("Login", showLabel: false)]
[Button("登录", ButtonSizes.Large)] [Button("登录", ButtonSizes.Large)]
[InfoBox("@ message", InfoMessageType.Info)] [InfoBox("@ message", InfoMessageType.Info)]
@@ -156,7 +153,7 @@ namespace Stary.Evo.Editor
} }
[BoxGroup("Build", showLabel: false)] [BoxGroup("Build", showLabel: false)]
[ShowIf("@ buildAssetType== Stary.Evo.BuildOriginality.BuildAssetType.Build")] [ShowIf("IsBuild")]
[Title("包裹列表", titleAlignment: TitleAlignments.Centered)] [Title("包裹列表", titleAlignment: TitleAlignments.Centered)]
[HorizontalGroup("Build/BuildPipeline"), HideLabel] [HorizontalGroup("Build/BuildPipeline"), HideLabel]
[ValueDropdown("GetBuildPackageNames")] [ValueDropdown("GetBuildPackageNames")]
@@ -164,7 +161,7 @@ namespace Stary.Evo.Editor
public string selectedPackageNames; public string selectedPackageNames;
[BoxGroup("Build", showLabel: false)] [BoxGroup("Build", showLabel: false)]
[ShowIf("@ buildAssetType== Stary.Evo.BuildOriginality.BuildAssetType.Build")] [ShowIf("IsBuild")]
[Title("当前打包平台", titleAlignment: TitleAlignments.Centered)] [Title("当前打包平台", titleAlignment: TitleAlignments.Centered)]
[ReadOnly] [ReadOnly]
[HorizontalGroup("Build/BuildPipeline"), HideLabel] [HorizontalGroup("Build/BuildPipeline"), HideLabel]
@@ -175,7 +172,7 @@ namespace Stary.Evo.Editor
[Title("版本号", titleAlignment: TitleAlignments.Centered)] [Title("版本号", titleAlignment: TitleAlignments.Centered)]
[HorizontalGroup("Build/PackageVersion"), HideLabel] [HorizontalGroup("Build/PackageVersion"), HideLabel]
[ShowIf("@ buildAssetType== Stary.Evo.BuildOriginality.BuildAssetType.Build")] [ShowIf("IsBuild")]
[OnValueChanged("OnPackageValueChanged")] [OnValueChanged("OnPackageValueChanged")]
public string _packageVersion; public string _packageVersion;
@@ -253,13 +250,13 @@ namespace Stary.Evo.Editor
#region Update #region Update
[BoxGroup("Build", showLabel: false)] [BoxGroup("Build", showLabel: false)]
[ShowIf("@ buildAssetType== Stary.Evo.BuildOriginality.BuildAssetType.Build")] [ShowIf("IsBuild")]
[Title("打包本地资源", titleAlignment: TitleAlignments.Centered)] [Title("打包本地资源", titleAlignment: TitleAlignments.Centered)]
[HideLabel] [HideLabel]
public BuildAssetEntity onBuildPipelineEntity; public BuildAssetEntity onBuildPipelineEntity;
[BoxGroup("Build", showLabel: false)] [BoxGroup("Build", showLabel: false)]
[ShowIf("@ buildAssetType== Stary.Evo.BuildOriginality.BuildAssetType.Build")] [ShowIf("IsBuild")]
[Title("上传资源", titleAlignment: TitleAlignments.Centered)] [Title("上传资源", titleAlignment: TitleAlignments.Centered)]
[HideLabel] [HideLabel]
public BuildAssetEntity onUpdateBuildPipelineEntity; public BuildAssetEntity onUpdateBuildPipelineEntity;
@@ -428,9 +425,8 @@ namespace Stary.Evo.Editor
EditorUtility.ClearProgressBar(); EditorUtility.ClearProgressBar();
return; return;
} }
}
else if (resResultMessage.code == 200)
} else if (resResultMessage.code == 200)
{ {
EditorUtility.DisplayDialog("提示", EditorUtility.DisplayDialog("提示",
@@ -518,5 +514,15 @@ namespace Stary.Evo.Editor
onBuildPipelineEntity.SetButtonName($"打包资源包【版本:{_packageVersion}】"); onBuildPipelineEntity.SetButtonName($"打包资源包【版本:{_packageVersion}】");
onUpdateBuildPipelineEntity.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;
}
} }
} }

View File

@@ -33,7 +33,14 @@ namespace Stary.Evo.Editor
bool isOk = EditorUtility.DisplayDialog("提示", "是否检索并创建缺失目录", "是", "否"); bool isOk = EditorUtility.DisplayDialog("提示", "是否检索并创建缺失目录", "是", "否");
if (isOk) if (isOk)
{ {
ArtServerManageWindow.CreateDomainDirectory(DomainName); // 获取或创建ArtServerManageWindow面板
ArtServerManageWindow window = EditorWindow.GetWindow<ArtServerManageWindow>();
if (window != null)
{
window.CreateDomainDirectory(DomainName);
}
} }
} }
[HorizontalGroup(Width = 60)] [HorizontalGroup(Width = 60)]
@@ -50,7 +57,7 @@ namespace Stary.Evo.Editor
{ {
BuildArtAssetWindow.RemoveBuildAssetWindow(); BuildArtAssetWindow.RemoveBuildAssetWindow();
EditorFrameworkUtils.DeleteAllChild(domainPath, FileAttributes.Normal); EditorFrameworkUtils.DeleteAllChild(domainPath, FileAttributes.Normal);
domainList.Clear(); domainList.Remove(this);
AssetDatabase.Refresh(); AssetDatabase.Refresh();
AssetDatabase.SaveAssets(); AssetDatabase.SaveAssets();

View File

@@ -10,11 +10,11 @@ using UnityEngine;
namespace Stary.Evo.Editor namespace Stary.Evo.Editor
{ {
[Serializable] [Serializable]
public class CreatArtServerDomainEntity public class CreatMemberServerDomainEntity
{ {
private string ip; private string ip;
private List<CreatArtServerDomainEntity> domainList; private List<CreatMemberServerDomainEntity> domainList;
[HorizontalGroup] [ReadOnly] public string DomainName; [HorizontalGroup] [ReadOnly] public string DomainName;
@@ -29,7 +29,7 @@ namespace Stary.Evo.Editor
[InlineEditor(InlineEditorObjectFieldModes.CompletelyHidden)] [InlineEditor(InlineEditorObjectFieldModes.CompletelyHidden)]
[HideLabel] [HideLabel]
public ArtSceneData artSceneData; public ArtSceneData artSceneData;
public CreatArtServerDomainEntity(List<CreatArtServerDomainEntity> domainList) public CreatMemberServerDomainEntity(List<CreatMemberServerDomainEntity> domainList)
{ {
this.domainList = domainList; this.domainList = domainList;
} }
@@ -50,7 +50,7 @@ namespace Stary.Evo.Editor
_endableBtnColor = Color.red; _endableBtnColor = Color.red;
} }
string artSceneDataPath = string artSceneDataPath =
$"Assets/Art/{domainName}/Config/ArtSceneData.asset"; $"Assets/Member/{domainName}/Config/ArtSceneData.asset";
ArtSceneData artSceneData = ArtSceneData artSceneData =
AssetDatabase.LoadAssetAtPath<ArtSceneData>(artSceneDataPath); AssetDatabase.LoadAssetAtPath<ArtSceneData>(artSceneDataPath);
if (artSceneData != null) if (artSceneData != null)
@@ -75,7 +75,11 @@ namespace Stary.Evo.Editor
bool isOk = EditorUtility.DisplayDialog("提示", "是否检索并创建缺失目录", "是", "否"); bool isOk = EditorUtility.DisplayDialog("提示", "是否检索并创建缺失目录", "是", "否");
if (isOk) if (isOk)
{ {
ArtServerManageWindow.CreateDomainDirectory(DomainName); ArtServerManageWindow window = EditorWindow.GetWindow<ArtServerManageWindow>();
if (window != null)
{
window.CreateDomainDirectory(DomainName);
}
} }
} }

View File

@@ -1,7 +1,6 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.IO; using System.IO;
using UnityEditor; using UnityEditor;
using UnityEditor.U2D; using UnityEditor.U2D;
using UnityEngine; using UnityEngine;
@@ -16,28 +15,123 @@ namespace Stary.Evo.Editor
private static string _packageName; 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) public static void AddArtMark(Action complete)
{ {
_packageName = BuildArtAssetWindow.GetBuildPackageName(); _packageName = BuildArtAssetWindow.GetBuildPackageName();
CopyArtScenes();
AssetBundleCollectorPackage assetBundleCollectorPackage = null; AssetBundleCollectorPackage assetBundleCollectorPackage = null;
foreach (var package in AssetBundleCollectorSettingData.Setting.Packages) foreach (var package in AssetBundleCollectorSettingData.Setting.Packages)
{ {
if (package.PackageName ==_packageName) if (package.PackageName == _packageName)
{ {
assetBundleCollectorPackage = package; assetBundleCollectorPackage = package;
} }
} }
if (assetBundleCollectorPackage != null) if (assetBundleCollectorPackage != null)
{ {
YooAsset.Editor.AssetBundleCollectorSettingData.RemovePackage(assetBundleCollectorPackage); YooAsset.Editor.AssetBundleCollectorSettingData.RemovePackage(assetBundleCollectorPackage);
} }
MarkArt(); MarkArt();
CollectSVC(ArtRoot, _packageName,complete); CollectSVC(AbsoluteMemberRoot, _packageName, complete);
} }
@@ -53,7 +147,7 @@ namespace Stary.Evo.Editor
addressDic.Clear(); addressDic.Clear();
collectorGroupDic.Clear(); collectorGroupDic.Clear();
///创建分组 ///创建分组
string remotedRoot = $"{ArtRoot}/{_packageName}"; string remotedRoot = $"{AbsoluteMemberRoot}/{_packageName}";
DirectoryInfo[] dirs = new DirectoryInfo(remotedRoot).GetDirectories(); DirectoryInfo[] dirs = new DirectoryInfo(remotedRoot).GetDirectories();
var setting = YooAsset.Editor.AssetBundleCollectorSettingData.Setting; var setting = YooAsset.Editor.AssetBundleCollectorSettingData.Setting;
@@ -74,7 +168,7 @@ namespace Stary.Evo.Editor
{ {
string groupName = info.Name; string groupName = info.Name;
if (info.Name == "Scenes"||info.Name == "Config") if (info.Name == "Scenes" || info.Name == "Config")
{ {
AssetBundleCollectorGroup collectorGroup = AssetBundleCollectorGroup collectorGroup =
YooAsset.Editor.AssetBundleCollectorSettingData.CreateGroup(package, groupName); YooAsset.Editor.AssetBundleCollectorSettingData.CreateGroup(package, groupName);
@@ -87,9 +181,11 @@ namespace Stary.Evo.Editor
{ {
Debug.LogError("分组 " + groupName + "已存在,请检查资源目录,避免重复"); Debug.LogError("分组 " + groupName + "已存在,请检查资源目录,避免重复");
} }
AutoMarkRootAddress(info); AutoMarkRootAddress(info);
} }
} }
// AssetDatabase.SaveAssets(); // AssetDatabase.SaveAssets();
// AssetDatabase.Refresh(); // AssetDatabase.Refresh();
MarkStatus(); 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) 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 remotedRoot = $"{root}/{packageName}/ShaderVariants";
string remotedRootFileName = $"{remotedRoot}/{packageName}.shadervariants"; string remotedRootFileName = $"{remotedRoot}/{packageName}.shadervariants";

View File

@@ -1,6 +1,6 @@
{ {
"name": "com.staryevo.buildoriginality", "name": "com.staryevo.buildoriginality",
"version": "1.0.5", "version": "1.0.6",
"displayName": "00.StaryEvo.BuildOriginality", "displayName": "00.StaryEvo.BuildOriginality",
"description": "美术打包工具", "description": "美术打包工具",
"unity": "2021.3", "unity": "2021.3",

View File

@@ -31,7 +31,7 @@ namespace Stary.Evo.Editor
public static OdinEditorWindow window; public static OdinEditorWindow window;
private HotfixMainResDomain hotfixMainResDomain; private HotfixMainResDomain hotfixMainResDomain;
[MenuItem("Evo/Dev/资源打包工具",false, 2)] [MenuItem("Evo/Dev/资源打包工具", false, 2)]
static void ShowWindows() static void ShowWindows()
{ {
#if NotUpdate #if NotUpdate
@@ -71,10 +71,11 @@ namespace Stary.Evo.Editor
else else
{ {
ip = hotfixMainResDomain.hotfixMainResDomainEntity.ipconfig; ip = hotfixMainResDomain.hotfixMainResDomainEntity.ipconfig;
EditorPrefs.SetString("ip",ip); EditorPrefs.SetString("ip", ip);
userName = hotfixMainResDomain.hotfixMainResDomainEntity.username; userName = hotfixMainResDomain.hotfixMainResDomainEntity.username;
password = hotfixMainResDomain.hotfixMainResDomainEntity.password; password = hotfixMainResDomain.hotfixMainResDomainEntity.password;
} }
GetBuildPackageNames(); GetBuildPackageNames();
if (string.IsNullOrEmpty(ip)) if (string.IsNullOrEmpty(ip))
{ {
@@ -103,12 +104,10 @@ namespace Stary.Evo.Editor
#region BuildAssetLogin #region BuildAssetLogin
[ShowIf("@ buildAssetType== Stary.Evo.BuildAssetType.Login")] [ShowIf("IsLogin")] [BoxGroup("Login", showLabel: false)] [OnValueChanged("SetWebRequestInfo")]
[BoxGroup("Login", showLabel: false)]
[OnValueChanged("SetWebRequestInfo")]
public string ip, userName, password; public string ip, userName, password;
[ShowIf("@ buildAssetType== Stary.Evo.BuildAssetType.Login")] [ShowIf("IsLogin")]
[BoxGroup("Login", showLabel: false)] [BoxGroup("Login", showLabel: false)]
[Button("登录", ButtonSizes.Large)] [Button("登录", ButtonSizes.Large)]
[InfoBox("@ message", InfoMessageType.Info)] [InfoBox("@ message", InfoMessageType.Info)]
@@ -129,6 +128,8 @@ namespace Stary.Evo.Editor
UpdateMessage(islogin); UpdateMessage(islogin);
} }
private void SetWebRequestInfo() private void SetWebRequestInfo()
{ {
if (hotfixMainResDomain != null) if (hotfixMainResDomain != null)
@@ -136,7 +137,7 @@ namespace Stary.Evo.Editor
hotfixMainResDomain.hotfixMainResDomainEntity.ipconfig = ip; hotfixMainResDomain.hotfixMainResDomainEntity.ipconfig = ip;
hotfixMainResDomain.hotfixMainResDomainEntity.username = userName; hotfixMainResDomain.hotfixMainResDomainEntity.username = userName;
hotfixMainResDomain.hotfixMainResDomainEntity.password = password; hotfixMainResDomain.hotfixMainResDomainEntity.password = password;
EditorPrefs.SetString("ip",ip); EditorPrefs.SetString("ip", ip);
EditorUtility.SetDirty(hotfixMainResDomain); EditorUtility.SetDirty(hotfixMainResDomain);
AssetDatabase.SaveAssets(); AssetDatabase.SaveAssets();
} }
@@ -163,7 +164,7 @@ namespace Stary.Evo.Editor
} }
[BoxGroup("Build", showLabel: false)] [BoxGroup("Build", showLabel: false)]
[ShowIf("@ buildAssetType== Stary.Evo.BuildAssetType.Build")] [ShowIf("IsBuild")]
[Title("包裹列表", titleAlignment: TitleAlignments.Centered)] [Title("包裹列表", titleAlignment: TitleAlignments.Centered)]
[HorizontalGroup("Build/BuildPipeline"), HideLabel] [HorizontalGroup("Build/BuildPipeline"), HideLabel]
[ValueDropdown("GetBuildPackageNames")] [ValueDropdown("GetBuildPackageNames")]
@@ -171,7 +172,7 @@ namespace Stary.Evo.Editor
public string selectedPackageNames; public string selectedPackageNames;
[BoxGroup("Build", showLabel: false)] [BoxGroup("Build", showLabel: false)]
[ShowIf("@ buildAssetType== Stary.Evo.BuildAssetType.Build")] [ShowIf("IsBuild")]
[Title("当前打包平台", titleAlignment: TitleAlignments.Centered)] [Title("当前打包平台", titleAlignment: TitleAlignments.Centered)]
[ReadOnly] [ReadOnly]
[HorizontalGroup("Build/BuildPipeline"), HideLabel] [HorizontalGroup("Build/BuildPipeline"), HideLabel]
@@ -200,7 +201,7 @@ namespace Stary.Evo.Editor
#region MarkAsset #region MarkAsset
[BoxGroup("Build", showLabel: false)] [BoxGroup("Build", showLabel: false)]
[ShowIf("@ buildAssetType== Stary.Evo.BuildAssetType.Build")] [ShowIf("IsBuild")]
[Title("标记资源", titleAlignment: TitleAlignments.Centered)] [Title("标记资源", titleAlignment: TitleAlignments.Centered)]
[HorizontalGroup("Build/HyBridClrBuildEntity"), HideLabel] [HorizontalGroup("Build/HyBridClrBuildEntity"), HideLabel]
public BuildAssetEntity markAssetEntity = public BuildAssetEntity markAssetEntity =
@@ -211,7 +212,7 @@ namespace Stary.Evo.Editor
#region BuildAsset #region BuildAsset
[BoxGroup("Build", showLabel: false)] [BoxGroup("Build", showLabel: false)]
[ShowIf("@ buildAssetType== Stary.Evo.BuildAssetType.Build")] [ShowIf("IsBuild")]
[InlineEditor(InlineEditorObjectFieldModes.CompletelyHidden)] [InlineEditor(InlineEditorObjectFieldModes.CompletelyHidden)]
[HideLabel] [HideLabel]
public BuildAssetDataSetting BuildAssetDataSetting; public BuildAssetDataSetting BuildAssetDataSetting;
@@ -292,7 +293,7 @@ namespace Stary.Evo.Editor
#region Update #region Update
[BoxGroup("Build", showLabel: false)] [BoxGroup("Build", showLabel: false)]
[ShowIf("@ buildAssetType== Stary.Evo.BuildAssetType.Build")] [ShowIf("IsBuild")]
[Title("打包本地资源", titleAlignment: TitleAlignments.Centered)] [Title("打包本地资源", titleAlignment: TitleAlignments.Centered)]
[HideLabel] [HideLabel]
public BuildAssetEntity onBuildPipelineEntity; public BuildAssetEntity onBuildPipelineEntity;
@@ -300,8 +301,7 @@ namespace Stary.Evo.Editor
[BoxGroup("Build", showLabel: false)] [BoxGroup("Build", showLabel: false)]
[Title("上传资源", titleAlignment: TitleAlignments.Centered)] [Title("上传资源", titleAlignment: TitleAlignments.Centered)]
[HideLabel] [HideLabel]
[ShowIf( [ShowIf("@ IsRelease() && IsBuild()")]
"@ BuildAssetDataSetting.environmentType== EnvironmentType.Release && buildAssetType== Stary.Evo.BuildAssetType.Build")]
public BuildAssetEntity onUpdateBuildPipelineEntity; public BuildAssetEntity onUpdateBuildPipelineEntity;
@@ -415,7 +415,6 @@ namespace Stary.Evo.Editor
// 执行拷贝操作 // 执行拷贝操作
File.Copy(sourcePath, destinationPath); File.Copy(sourcePath, destinationPath);
} }
public static async Task UpdateFileDataResDomain(BuildAssetDataSetting setting, string zipFilePath) public static async Task UpdateFileDataResDomain(BuildAssetDataSetting setting, string zipFilePath)
@@ -556,8 +555,24 @@ namespace Stary.Evo.Editor
onBuildPipelineEntity.SetButtonName($"打包资源包【版本:{BuildAssetDataSetting.packageVersion}】"); onBuildPipelineEntity.SetButtonName($"打包资源包【版本:{BuildAssetDataSetting.packageVersion}】");
onUpdateBuildPipelineEntity.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;
}
}
} }

View File

@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 443e7176dc1c439ab6d9ffbf3e38a2c7
timeCreated: 1762222048

View File

@@ -0,0 +1,7 @@
namespace Stary.Evo.OdinDrawerAttribute
{
public class OdinDrawerAttribute
{
}
}

View File

@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: dfa0ecbdc2e043ec87148405e329a5cd
timeCreated: 1762222058

View File

@@ -1,6 +1,6 @@
{ {
"name": "com.staryevo.tools", "name": "com.staryevo.tools",
"version": "1.1.18", "version": "1.1.19",
"displayName": "00.StaryEvo.Tools", "displayName": "00.StaryEvo.Tools",
"description": "This is an Framework package(后台服务器版本端口9527)", "description": "This is an Framework package(后台服务器版本端口9527)",
"unity": "2021.3", "unity": "2021.3",