【m】框架大更新

This commit is contained in:
2025-10-31 11:18:23 +08:00
parent ae6e7c804b
commit 8e1d52ddbf
1883 changed files with 213934 additions and 640 deletions

View File

@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 2cd668ef4a6d430ca732c04053d23808
timeCreated: 1761817206

View File

@@ -0,0 +1,67 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Threading.Tasks;
using Newtonsoft.Json;
using UnityEngine;
namespace Stary.Evo.Editor
{
public static class ArtLoadAssetLocal
{
/// <summary>
/// 获取本地全部作用域
/// </summary>
public static string[] GetLocalDomainAllName()
{
var creatDomainEntities = GetLocalDomainAll();
string[] domains = new string[creatDomainEntities.Count];
for (int i = 0; i < creatDomainEntities.Count; i++)
{
domains[i] = creatDomainEntities[i].DomainName;
}
return domains;
}
/// <summary>
/// 获取全部作用域
/// </summary>
public static List<CreatArtDomainEntity> GetLocalDomainAll()
{
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 (File.Exists($"{domainPath}/{item}/Scenes/TestScene.unity"))
{
CreatArtDomainEntity domainEntity = new CreatArtDomainEntity(domainList)
{
DomainName = item,
domainPath = $"{domainPath}/{item}"
};
domainList.Add(domainEntity);
}
}
return domainList;
}
}
}

View File

@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: f0b4f8af6dd9440e94d32f7cc565a430
timeCreated: 1761727096

View File

@@ -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();
}
}
}

View File

@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 59d31311b3e14ae99453fab351e1fcf3
timeCreated: 1761545309

View File

@@ -27,14 +27,9 @@ namespace Stary.Evo.Editor
public static OdinEditorWindow window;
private HotfixMainResDomain hotfixMainResDomain;
[MenuItem("Evo/Art/Art资源打包工具",false, 1)]
[MenuItem("Evo/Art/Art资源打包工具", false, 1)]
static void ShowWindows()
{
if (CreatAssetWindow.GetCreatDomainAll().Count <= 0)
{
EditorUtility.DisplayDialog("提示", "不存在Art元素无法打开此面板请先创建Art元素", "确定");
return;
}
window = (BuildArtAssetWindow)EditorWindow.GetWindow(typeof(BuildArtAssetWindow));
window.Show();
@@ -44,12 +39,12 @@ namespace Stary.Evo.Editor
{
base.OnDisable();
EditorUtility.ClearProgressBar();
packageName = "";
}
protected override async void Initialize()
{
base.Initialize();
GetBuildPackageNames();
//初始化读取资源配置表
hotfixMainResDomain = Resources.Load<HotfixMainResDomain>("HotfixMainResDomain");
if (hotfixMainResDomain == null)
@@ -64,6 +59,7 @@ namespace Stary.Evo.Editor
password = hotfixMainResDomain.hotfixMainResDomainEntity.password;
}
GetBuildPackageNames();
if (string.IsNullOrEmpty(ip))
{
buildAssetType = BuildAssetType.Login;
@@ -83,7 +79,7 @@ namespace Stary.Evo.Editor
//初始化打包管线
_buildPipelineViewer = new ScriptableBuildPipelineViewer(packageName,
EBuildPipeline.ScriptableBuildPipeline.ToString(), packageVersion);
EBuildPipeline.ScriptableBuildPipeline.ToString(), _packageVersion);
_buildPipelineViewer.clearBuildCacheToggle = true;
_buildPipelineViewer.useAssetDependencyDBToggle = false;
_buildPipelineViewer.SetBuildCacheToggle();
@@ -176,12 +172,23 @@ namespace Stary.Evo.Editor
private static string packageName;
[Title("版本号", titleAlignment: TitleAlignments.Centered)]
[HorizontalGroup("Build/PackageVersion"), HideLabel]
[ShowIf("@ buildAssetType== BuildAssetType.Build")]
[OnValueChanged("OnPackageValueChanged")]
public string packageVersion;
public string _packageVersion;
private string PackageVersion
{
get { return _packageVersion; }
set
{
_packageVersion = value;
if (_buildPipelineViewer != null)
_buildPipelineViewer.SetBuildPackagePackageVersion(_packageVersion);
}
}
private AbstractBuildPipelineViewer _buildPipelineViewer;
@@ -190,8 +197,9 @@ namespace Stary.Evo.Editor
public void OnPackageValueChanged()
{
_buildPipelineViewer.SetBuildPackageData(packageName, EBuildPipeline.ScriptableBuildPipeline.ToString(),
packageVersion);
if (_buildPipelineViewer != null)
_buildPipelineViewer.SetBuildPackageData(packageName, EBuildPipeline.ScriptableBuildPipeline.ToString(),
_packageVersion);
}
/// <summary>
@@ -201,7 +209,7 @@ namespace Stary.Evo.Editor
private List<string> GetBuildPackageNames()
{
List<string> result = new List<string>();
foreach (var name in CreatArtAssetWindow.GetCreatDomainAllName())
foreach (var name in ArtLoadAssetLocal.GetLocalDomainAllName())
{
result.Add(name);
}
@@ -259,7 +267,8 @@ namespace Stary.Evo.Editor
private void OnBuildPipeline()
{
if (EditorUtility.DisplayDialog("提示", $"开始构建资源包[{selectedPackageNames}]", "Yes", "No"))
if (EditorUtility.DisplayDialog("提示",
$"开始构建资源包[{selectedPackageNames}],版本号为[{_buildPipelineViewer.packageVersion}]", "Yes", "No"))
{
EditorTools.ClearUnityConsole();
MarkAdressable.AddArtMark(() => { EditorApplication.delayCall += _buildPipelineViewer.ExecuteBuild; });
@@ -272,7 +281,8 @@ namespace Stary.Evo.Editor
private async void OnUpdateBuildPipeline()
{
if (EditorUtility.DisplayDialog("提示", $"开始上传至服务器[{selectedPackageNames}]", "Yes", "No"))
if (EditorUtility.DisplayDialog("提示",
$"开始上传至服务器[{selectedPackageNames}],,版本号为[{_buildPipelineViewer.packageVersion}", "Yes", "No"))
{
// 新增打包为zip的逻辑
string zipFilePath = BuildZip();
@@ -294,13 +304,13 @@ namespace Stary.Evo.Editor
EditorUtility.DisplayProgressBar("提示", $"开始上传{packageName}(打包zip)", 0.0f);
// 新增打包为zip的逻辑
string zipFileName =
$"{packageName}_{packageVersion}.zip";
$"{packageName}_{_packageVersion}.zip";
//原yooAsset目录
var outputPackageDirectory =
$"{AssetBundleBuilderHelper.GetDefaultBuildOutputRoot()}/{EditorUserBuildSettings.activeBuildTarget}/{packageName}";
//拷贝目录
string outFilePath = $"{outputPackageDirectory}/{packageVersion}";
string outFilePath = $"{outputPackageDirectory}/{_packageVersion}";
var copyPackageDirectory =
$"{Application.streamingAssetsPath}/{YooAssetSettingsData.GetDefaultYooFolderName()}/{packageName}";
@@ -398,7 +408,7 @@ namespace Stary.Evo.Editor
ProductName = Application.identifier,
DomainName = packageName,
Platform = EditorUserBuildSettings.activeBuildTarget.ToString(),
PackageVersion = packageVersion,
PackageVersion = _packageVersion,
DocumentFileId = fileId
};
var resResultMessage = await WebRequestSystem.Post(ip + "/ResDomain/AddResDomain",
@@ -424,11 +434,11 @@ namespace Stary.Evo.Editor
string versionWithoutEndDigits =
System.Text.RegularExpressions.Regex.Replace(dmainVersionResponse.PackageVersion,
@"\d+$", "");
packageVersion = versionWithoutEndDigits + versionEndDigit;
PackageVersion = versionWithoutEndDigits + versionEndDigit;
}
EditorUtility.DisplayDialog("提示",
$"{resResultMessage.message + $"\n{resResultMessage.data.ToString()},{packageVersion}"}",
$"{resResultMessage.message + $"\n{resResultMessage.data.ToString()},{_packageVersion}"}",
"确定");
}
}
@@ -467,7 +477,7 @@ namespace Stary.Evo.Editor
ResDmainResponse domainResponse =
JsonConvert.DeserializeObject<ResDmainResponse>(resResultMessage.data
.ToString());
packageVersion = domainResponse.PackageVersion;
PackageVersion = domainResponse.PackageVersion;
}
else
{
@@ -478,7 +488,7 @@ namespace Stary.Evo.Editor
{
EditorUtility.DisplayDialog("提示",
$"{resResultMessage.message},默认test_1.0版本 ", "确定");
packageVersion = "test_1.0";
PackageVersion = "test_1.0";
}
}
@@ -489,9 +499,9 @@ namespace Stary.Evo.Editor
//Update
buildTarget = EditorUserBuildSettings.activeBuildTarget.ToString();
onBuildPipelineEntity =
new BuildAssetEntity("打包", $"打包资源包【版本:{packageVersion}】", OnBuildPipeline);
new BuildAssetEntity("打包", $"打包资源包【版本:{_packageVersion}】", OnBuildPipeline);
onUpdateBuildPipelineEntity =
new BuildAssetEntity("更新", $"更新至服务器【版本:{packageVersion}】",
new BuildAssetEntity("更新", $"更新至服务器【版本:{_packageVersion}】",
OnUpdateBuildPipeline);
}
@@ -509,8 +519,8 @@ namespace Stary.Evo.Editor
public void UpdateBuildPipelineButtonName()
{
onBuildPipelineEntity.SetButtonName($"打包资源包【版本:{packageVersion}】");
onUpdateBuildPipelineEntity.SetButtonName($"更新至服务器【版本:{packageVersion}】");
onBuildPipelineEntity.SetButtonName($"打包资源包【版本:{_packageVersion}】");
onUpdateBuildPipelineEntity.SetButtonName($"更新至服务器【版本:{_packageVersion}】");
}
}
}

View File

@@ -33,7 +33,7 @@ namespace Stary.Evo.Editor
bool isOk = EditorUtility.DisplayDialog("提示", "是否检索并创建缺失目录", "是", "否");
if (isOk)
{
CreatAssetWindow.CreateDomainDirectory(DomainName);
ArtServerManageWindow.CreateDomainDirectory(DomainName);
}
}
[HorizontalGroup(Width = 60)]

View File

@@ -0,0 +1,185 @@
using System;
using System.Collections.Generic;
using System.IO;
using EditorFramework;
using Newtonsoft.Json;
using Sirenix.OdinInspector;
using UnityEditor;
using UnityEngine;
namespace Stary.Evo.Editor
{
[Serializable]
public class CreatArtServerDomainEntity
{
private string ip;
private List<CreatArtServerDomainEntity> domainList;
[HorizontalGroup] [ReadOnly] public string DomainName;
private bool IsValidPath => IsValidProjectPath(domainPath);
[ReadOnly] [InfoBox("当前路径在Unity项目中不存在,请检查路径是否需要删除", InfoMessageType.Error, "IsValidPath")]
public string domainPath;
private ResDmainResponse resDmainResponse;
[InlineEditor(InlineEditorObjectFieldModes.CompletelyHidden)]
[HideLabel]
public ArtSceneData artSceneData;
public CreatArtServerDomainEntity(List<CreatArtServerDomainEntity> domainList)
{
this.domainList = domainList;
}
public void SetDomainData(string domainName, string domainPath, ResDmainResponse response, string ip)
{
resDmainResponse = response;
DomainName = domainName;
this.domainPath = domainPath;
this.ip = ip;
if (!resDmainResponse.IsEnable)
{
_endableBtnName = "启用";
_endableBtnColor = Color.green;
}
else
{
_endableBtnName = "禁用";
_endableBtnColor = Color.red;
}
string artSceneDataPath =
$"Assets/Art/{domainName}/Config/ArtSceneData.asset";
ArtSceneData artSceneData =
AssetDatabase.LoadAssetAtPath<ArtSceneData>(artSceneDataPath);
if (artSceneData != null)
{
this.artSceneData = artSceneData;
}
else
{
Debug.LogError($"UnityEvo:ArtSceneData 不存在,请检查路径{artSceneDataPath}");
}
}
[HorizontalGroup(Width = 60)]
[Button("", Icon = SdfIconType.ArrowRepeat, IconAlignment = IconAlignment.RightEdge)]
public void CreatDomain()
{
if (DomainName == "Main")
{
EditorUtility.DisplayDialog("提示", "主包Main作用域无法再次创建", "确定");
return;
}
bool isOk = EditorUtility.DisplayDialog("提示", "是否检索并创建缺失目录", "是", "否");
if (isOk)
{
ArtServerManageWindow.CreateDomainDirectory(DomainName);
}
}
[HorizontalGroup(Width = 60)]
[Button("", Icon = SdfIconType.XCircle, IconAlignment = IconAlignment.RightEdge)]
public async void CloseDomain()
{
if (DomainName == "Main")
{
EditorUtility.DisplayDialog("提示", "主包Main作用域无法删除", "确定");
return;
}
bool isOk = EditorUtility.DisplayDialog("提示", "是否删除此Art", "是", "否");
if (isOk)
{
string url = $"{ip}/ResDomain/DeleteResDomain";
var requst = new ResDmainRequst()
{
ProductName = Application.identifier,
Platform = UnityEditor.EditorUserBuildSettings.activeBuildTarget.ToString(),
DomainName = DomainName,
};
var resDmainMessageEntity =
await WebRequestSystem.Post(url, JsonConvert.SerializeObject(requst));
if (resDmainMessageEntity.code == 200)
{
BuildArtAssetWindow.RemoveBuildAssetWindow();
EditorFrameworkUtils.DeleteAllChild(domainPath, FileAttributes.Normal);
domainList.Remove(this);
AssetDatabase.Refresh();
AssetDatabase.SaveAssets();
EditorUtility.DisplayDialog("提示", "删除成功", "确定");
}
else
{
EditorUtility.DisplayDialog("提示", $"删除失败,错误码:{resDmainMessageEntity.code}", "确定");
}
}
}
private string _endableBtnName = "";
private Color _endableBtnColor = Color.white;
private bool IsReadOnly = false; // 或者根据条件动态判断
[HorizontalGroup(Width = 60)]
[Button("@ _endableBtnName", IconAlignment = IconAlignment.RightEdge)]
[GUIColor("@ _endableBtnColor")]
[DisableIf("@ IsReadOnly")]
public async void IsEndable()
{
if (DomainName == "Main")
{
EditorUtility.DisplayDialog("提示", "主包Main作用域设置", "确定");
return;
}
resDmainResponse.IsEnable = !resDmainResponse.IsEnable;
if (!resDmainResponse.IsEnable)
{
_endableBtnName = "启用";
_endableBtnColor = Color.green;
}
else
{
_endableBtnName = "禁用";
_endableBtnColor = Color.red;
}
string url = $"{ip}/ResDomain/UpdateResDomain";
var requst = new ResDmainUpdateRequst()
{
ProductName = Application.identifier,
Platform = UnityEditor.EditorUserBuildSettings.activeBuildTarget.ToString(),
DomainName = DomainName,
IsEnabled = resDmainResponse.IsEnable,
};
IsReadOnly = true;
//获取服务器版本
var resDmainMessageEntity =
await WebRequestSystem.Put(url, JsonConvert.SerializeObject(requst));
IsReadOnly = false;
}
/// <summary>
/// 检查给定路径是否在Unity项目中存在
/// </summary>
/// <param name="path">要检查的路径</param>
/// <returns>路径是否存在</returns>
private bool IsValidProjectPath(string path)
{
if (string.IsNullOrEmpty(path))
return false;
// 将相对路径转换为绝对路径进行检查
string fullPath = Path.GetFullPath(path);
string projectPath = Path.GetFullPath(Application.dataPath + "/../");
// 确保路径在项目目录内
if (!fullPath.StartsWith(projectPath))
return false;
// 检查路径是否存在
return !(Directory.Exists(path) || File.Exists(path));
}
}
}

View File

@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: c3d6da1969234ea5b6e6f0b168d91da5
timeCreated: 1761617923

View File

@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 934c26c83686420e945161561b0b99e8
timeCreated: 1761819519

View File

@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 36a5d5f89250459abfcd0c160e9bfb0b
timeCreated: 1761819422

View File

@@ -16,9 +16,9 @@ namespace Stary.Evo.Editor
#region
protected string packageName;
public string packageName;
protected string selectedBuildPipelines;
protected string packageVersion;
public string packageVersion;
#endregion
// protected bool isSimulate;
@@ -89,6 +89,14 @@ namespace Stary.Evo.Editor
this.selectedBuildPipelines = selectedBuildPipelines;
this.packageVersion = packageVersion;
}
public void SetBuildPackagePackageName(string packageName)
{
this.packageName = packageName;
}
public void SetBuildPackagePackageVersion(string packageVersion)
{
this.packageVersion = packageVersion;
}
#region AssetBuild
private void SetCompression()

View File

@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: a8b4c913d7454b44808ea667b10131ca
timeCreated: 1761819308

View File

@@ -0,0 +1,396 @@
using System;
using System.Collections.Generic;
using System.IO;
using UnityEditor;
using UnityEditor.U2D;
using UnityEngine;
using UnityEngine.U2D;
using YooAsset.Editor;
namespace Stary.Evo.Editor
{
public class MarkAdressable
{
private static AssetBundleCollectorPackage package;
private static string _packageName;
public static string ArtRoot
{
get { return Application.dataPath + "/Art"; }
}
public static void AddArtMark(Action complete)
{
_packageName = BuildArtAssetWindow.GetBuildPackageName();
AssetBundleCollectorPackage assetBundleCollectorPackage = null;
foreach (var package in AssetBundleCollectorSettingData.Setting.Packages)
{
if (package.PackageName ==_packageName)
{
assetBundleCollectorPackage = package;
}
}
if (assetBundleCollectorPackage != null)
{
YooAsset.Editor.AssetBundleCollectorSettingData.RemovePackage(assetBundleCollectorPackage);
}
MarkArt();
CollectSVC(ArtRoot, _packageName,complete);
}
#region
public static Dictionary<string, string> addressDic = new Dictionary<string, string>();
public static Dictionary<string, AssetBundleCollectorGroup> collectorGroupDic =
new Dictionary<string, AssetBundleCollectorGroup>();
public static void MarkArt()
{
addressDic.Clear();
collectorGroupDic.Clear();
///创建分组
string remotedRoot = $"{ArtRoot}/{_packageName}";
DirectoryInfo[] dirs = new DirectoryInfo(remotedRoot).GetDirectories();
var setting = YooAsset.Editor.AssetBundleCollectorSettingData.Setting;
setting.ShowPackageView = true;
setting.UniqueBundleName = true;
//创建Package文件
package = YooAsset.Editor.AssetBundleCollectorSettingData.CreatePackage(_packageName);
//检测Packages是否存在TestPackage
package.PackageName = _packageName;
package.EnableAddressable = true;
package.IncludeAssetGUID = true;
package.AutoCollectShaders = true;
package.IgnoreRuleName = "NormalIgnoreRule";
//检测Packages是否存在Group
foreach (var info in dirs)
{
string groupName = info.Name;
if (info.Name == "Scenes"||info.Name == "Config")
{
AssetBundleCollectorGroup collectorGroup =
YooAsset.Editor.AssetBundleCollectorSettingData.CreateGroup(package, groupName);
collectorGroup.AssetTags = groupName;
if (!collectorGroupDic.ContainsKey(groupName))
{
collectorGroupDic.Add(groupName, collectorGroup);
}
else
{
Debug.LogError("分组 " + groupName + "已存在,请检查资源目录,避免重复");
}
AutoMarkRootAddress(info);
}
}
// AssetDatabase.SaveAssets();
// AssetDatabase.Refresh();
MarkStatus();
YooAsset.Editor.AssetBundleCollectorSettingData.SaveFile();
// CreateRes();
Debug.Log("MarkAsset Successful");
}
public static void AutoMarkRootAddress(DirectoryInfo dir)
{
List<string> fileInfos = new List<string>();
FilesUtils.GetFiles(dir.FullName, ref fileInfos);
//检测用户config下是否存在config文件
if (dir.Name == "Config")
{
List<string> fileNewInfos = new List<string>();
foreach (var file in fileInfos)
{
if (Path.GetExtension(file) != ".meta")
{
fileNewInfos.Add(file);
}
}
}
if (fileInfos != null && fileInfos.Count > 0)
{
foreach (var file in fileInfos)
{
if (Path.GetExtension(file) != ".meta" && Path.GetExtension(file) != ".spriteatlas")
{
// string[] dirSplit = file.Split(new string[] { $"AddressableRes\\{dir.Name}\\" },
// StringSplitOptions.RemoveEmptyEntries);
// string address = (dirSplit[dirSplit.Length - 1]).Replace("\\", "/");
// Debug.Log("address" + address);
string groupName = dir.Name;
string assetPath = FilesUtils.AbsoluteToRelativePath("Assets", file); //Asset到文件的路径
var guid = AssetDatabase.AssetPathToGUID(assetPath);
var group = collectorGroupDic[groupName];
if (group != null)
{
AssetBundleCollector collector = new AssetBundleCollector()
{
CollectPath = assetPath,
CollectorGUID = guid,
CollectorType = ECollectorType.MainAssetCollector,
AddressRuleName = nameof(AddressByFolderAndFileName),
AssetTags = groupName,
};
//TODO 暂时不设置
// 如果是video目录设置
// if (groupName == "Video")
// {
// collector.PackRuleName = nameof(PackVideoFile);
// }
YooAsset.Editor.AssetBundleCollectorSettingData.CreateCollector(group, collector);
Debug.Log("GetAssetAddress:" + GetAssetAddress(file));
AddAddressInfo(file, GetAssetAddress(file));
}
else
{
Debug.LogError("分组 = " + groupName + "不存在");
}
}
}
}
}
#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)
{
if (addressDic.ContainsKey(assetPath))
{
Debug.LogError("命名重复,已经存在:" + assetPath);
}
else
{
addressDic.Add(assetPath, address);
}
}
private static string GetAssetAddress(string assetPath)
{
string fileName = Path.GetFileNameWithoutExtension(assetPath);
FileInfo fileInfo = new FileInfo(assetPath);
return $"{fileInfo.Directory.Name}_{fileName}";
}
#endregion
/// <summary>
/// 标记为资源分组
/// </summary>
private static void MarkStatus()
{
List<AssetBundleCollectorGroup> deleteList = new List<AssetBundleCollectorGroup>();
for (int i = 0; i < package.Groups.Count; i++)
{
var group = package.Groups[i];
if (group.GroupName != "Default Local Group" && group.GroupName != "Built In Data")
{
if (group.Collectors.Count <= 0)
{
///删除没有资源的分组
deleteList.Add(group);
}
}
}
for (int i = 0; i < deleteList.Count; i++)
{
package.Groups.Remove(deleteList[i]);
}
}
public static void CollectSVC(string root,string packageName,Action complete)
{
string remotedRoot = $"{root}/{packageName}/ShaderVariants";
string remotedRootFileName = $"{remotedRoot}/{packageName}.shadervariants";
if (!Directory.Exists(remotedRoot))
{
Directory.CreateDirectory(remotedRoot);
AssetDatabase.Refresh();
}
string localSavePath = FilesUtils.AbsoluteToRelativePath("Assets", remotedRootFileName); //Asset到文件的路径
System.Action completedCallback = () =>
{
ShaderVariantCollection collection =
AssetDatabase.LoadAssetAtPath<ShaderVariantCollection>(localSavePath);
if (collection != null)
{
Debug.Log(
$"UnityEvo:【{packageName}】ShaderCount : {collection.shaderCount}");
Debug.Log(
$"UnityEvo:【{packageName}】VariantCount : {collection.variantCount}");
CreateShaderVariantsGroup(packageName, localSavePath);
complete?.Invoke();
}
else
{
throw new Exception("Failed to Collect shader Variants.");
}
};
ShaderVariantCollector.Run(localSavePath, packageName, 1000, completedCallback);
}
// 新增方法创建独立的ShaderVariants分组防止多个package冲突
private static void CreateShaderVariantsGroup(string packageName, string localSavePath)
{
string groupname = $"ShaderVariants_{packageName}";
AssetBundleCollectorGroup collectorGroup = null;
// 查找或创建package专属分组
foreach (var package in AssetBundleCollectorSettingData.Setting.Packages)
{
if (package.PackageName == packageName)
{
collectorGroup = YooAsset.Editor.AssetBundleCollectorSettingData.CreateGroup(package, groupname);
break;
}
}
var guid = AssetDatabase.AssetPathToGUID(localSavePath);
AssetBundleCollector collector = new AssetBundleCollector()
{
CollectPath = localSavePath,
CollectorGUID = guid,
CollectorType = ECollectorType.MainAssetCollector,
AddressRuleName = nameof(AddressByFolderAndFileName),
PackRuleName = nameof(PackShaderVariants),
FilterRuleName = nameof(CollectShaderVariants),
AssetTags = groupname,
};
YooAsset.Editor.AssetBundleCollectorSettingData.CreateCollector(collectorGroup, collector);
YooAsset.Editor.AssetBundleCollectorSettingData.SaveFile();
}
}
}

View File

@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 65c4d04d2878442094e5e02e193d1133
timeCreated: 1761819535

View File

@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 958bd1b0596542c9aebda54d47bb62a7
timeCreated: 1761819298

View File

@@ -0,0 +1,22 @@
{
"name": "com.stary.buildoriginality.editor",
"rootNamespace": "",
"references": [
"com.stary.evo.runtime",
"com.stary.evo.editor",
"com.stary.buildoriginality.runtime",
"YooAsset",
"YooAsset.Editor"
],
"includePlatforms": [
"Editor"
],
"excludePlatforms": [],
"allowUnsafeCode": false,
"overrideReferences": false,
"precompiledReferences": [],
"autoReferenced": true,
"defineConstraints": [],
"versionDefines": [],
"noEngineReferences": false
}

View File

@@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: 9cc0d1f9e8badb1479f182b831d64109
AssemblyDefinitionImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 0bf40ebcbf1b4bfd80835e665dabe0ca
timeCreated: 1761817214

View File

@@ -0,0 +1,84 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Threading.Tasks;
using Newtonsoft.Json;
using UnityEngine;
namespace Stary.Evo
{
public static class ArtLoadAssetServer
{
public static string ip;
static ArtLoadAssetServer()
{
//初始化读取资源配置表
HotfixMainResDomain hotfixMainResDomain =
Resources.Load<HotfixMainResDomain>("HotfixMainResDomain");
if (hotfixMainResDomain == null)
{
Debug.LogError($"UnityEvo:读取资源配置表失败【HotfixMainResDomain】...表不存在");
}
ip = hotfixMainResDomain.hotfixMainResDomainEntity.ipconfig;
}
/// <summary>
/// 获取服务器全部作用域
/// </summary>
public async static Task<string[]> GetServerDomainAllName()
{
var serverDomainEntities = await GetServerDomainAll();
List<string> domains = new List<string>();
for (int i = 0; i < serverDomainEntities.Count; i++)
{
if (serverDomainEntities[i].IsEnable)
{
domains.Add(serverDomainEntities[i].DomainName);
}
}
return domains.ToArray();
}
/// <summary>
/// 获取全部作用域
/// </summary>
public static async Task<List<ResDmainResponse>> GetServerDomainAll()
{
//初始化读取资源配置表
HotfixMainResDomain hotfixMainResDomain =
Resources.Load<HotfixMainResDomain>("HotfixMainResDomain");
if (hotfixMainResDomain == null)
{
Debug.LogError($"UnityEvo:读取资源配置表失败【HotfixMainResDomain】...表不存在");
return null;
}
ip = hotfixMainResDomain.hotfixMainResDomainEntity.ipconfig;
//登录
string loginurl = ip + "/Authentication/login";
await WebRequestSystem.Login(loginurl, hotfixMainResDomain.hotfixMainResDomainEntity.username,
hotfixMainResDomain.hotfixMainResDomainEntity.password);
string url = $"{ip}/ResDomain/GetResDomainAll";
var resDmainRequst = new ResProductRequst()
{
ProductName = Application.identifier,
Platform = UnityEditor.EditorUserBuildSettings.activeBuildTarget.ToString(),
};
//获取服务器版本
var resDmainMessageEntity =
await WebRequestSystem.Post(url, JsonConvert.SerializeObject(resDmainRequst));
if (resDmainMessageEntity.code == 200)
{
List<ResDmainResponse> resDmainResponse =
JsonConvert.DeserializeObject<List<ResDmainResponse>>(resDmainMessageEntity.data.ToString());
return resDmainResponse;
}
return null;
}
}
}

View File

@@ -0,0 +1,19 @@
{
"name": "com.stary.buildoriginality.runtime",
"rootNamespace": "",
"references": [
"UniTask",
"DOTween.Modules",
"com.stary.evo.runtime",
"YooAsset"
],
"includePlatforms": [],
"excludePlatforms": [],
"allowUnsafeCode": false,
"overrideReferences": false,
"precompiledReferences": [],
"autoReferenced": true,
"defineConstraints": [],
"versionDefines": [],
"noEngineReferences": false
}

View File

@@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: 8c6fa7c2cd7bf784e856d9adb3dc2ada
AssemblyDefinitionImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,33 @@
{
"name": "com.stary.buildoriginality",
"version": "1.0.0",
"displayName": "00.StaryEvo.BuildOriginality",
"description": "美术打包工具",
"unity": "2021.3",
"unityRelease": "30f1",
"author": {
"name": "staryEvo",
"email": "zaze97@163.com",
"url": ""
},
"repository": {
"type": "git",
"url": "http://192.168.31.100:8088/framework/xosmopluginlibrary.git"
},
"dependencies": {
"com.cysharp.unitask": "2.5.10",
"com.tuyoogame.yooasset": "2.3.16"
},
"samples": [
{
"displayName": "Framework Example Scenes",
"description": "",
"path": "Samples~/Test"
},
{
"displayName": "Loading",
"description": "",
"path": "Samples~/SplashScreen"
}
]
}

View File

@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: da3e7243fb8957f42abb1aa79140e288
timeCreated: 1756370325

View File

@@ -1,183 +0,0 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
#if HotUpdate
using HybridCLR.Editor;
using HybridCLR.Editor.Settings;
#endif
using Sirenix.OdinInspector;
using Sirenix.OdinInspector.Editor;
using UnityEditor;
using UnityEditorInternal;
using UnityEngine;
namespace Stary.Evo.Editor
{
public class CreatArtAssetWindow : OdinEditorWindow
{
[MenuItem("Evo/Art/创建Art作用域",false, 0)]
static void Init()
{
// Get existing open window or if none, make a new one:
CreatArtAssetWindow window = (CreatArtAssetWindow)EditorWindow.GetWindow(typeof(CreatArtAssetWindow));
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");
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 = "RKCameraRig";
/* 6. 保存场景 */
string scenePath = Path.Combine("Assets/Art", domain, "Scenes", "TestScene.unity");
UnityEditor.SceneManagement.EditorSceneManager.SaveScene(newScene, scenePath);
}
AssetDatabase.SaveAssets();
AssetDatabase.Refresh();
}
[TitleGroup("预览Art作用域")]
[ListDrawerSettings(DraggableItems = false, ShowFoldout = false, ShowPaging = false, ShowItemCount = false,
HideRemoveButton = true, HideAddButton = true)]
public List<CreatArtDomainEntity> domainList;
protected override void Initialize()
{
base.Initialize();
domainList = GetCreatDomainAll();
}
/// <summary>
/// 获取全部作用域
/// </summary>
public static string[] GetCreatDomainAllName()
{
var creatDomainEntities = GetCreatDomainAll();
string[] domains = new string[creatDomainEntities.Count];
for (int i = 0; i < creatDomainEntities.Count; i++)
{
domains[i] = creatDomainEntities[i].DomainName;
}
return domains;
}
/// <summary>
/// 获取全部作用域
/// </summary>
public 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 (File.Exists($"{domainPath}/{item}/Scenes/TestScene.unity"))
{
CreatArtDomainEntity domainEntity = new CreatArtDomainEntity(domainList)
{
DomainName = item,
domainPath = $"{domainPath}/{item}"
};
domainList.Add(domainEntity);
}
}
return domainList;
}
private static void CreatDirectory(string artDomainPath)
{
if (!Directory.Exists(artDomainPath))
{
//创建Animation文件夹
Directory.CreateDirectory(artDomainPath);
}
}
}
}

View File

@@ -1,3 +0,0 @@
fileFormatVersion: 2
guid: f1b6f2585f9e4815aa16759ec152b390
timeCreated: 1744611618

View File

@@ -3,9 +3,7 @@
"rootNamespace": "",
"references": [
"com.stary.evo.runtime",
"Unity.ScriptableBuildPipeline.Editor",
"YooAsset",
"HybridCLR.Editor",
"YooAsset.Editor"
],
"includePlatforms": [

View File

@@ -68,23 +68,23 @@ namespace Stary.Evo
mArchitecture.IOCInitClass();
// 调用
OnRegisterPatch?.Invoke(mArchitecture);
// 初始化 Data
for (int i = 0; i < mArchitecture.mDatas.Count; i++)
{
mArchitecture.mDatas[i].Init();
}
// 清空 Data
// 清空 Data
//mArchitecture.mDatas.Clear();
// 初始化 System
for (int i = 0; i < mArchitecture.mSystems.Count; i++)
{
mArchitecture.mSystems[i].Init();
}
// 清空 System
// 清空 System
//mArchitecture.mSystems.Clear();
mArchitecture.mInited = true;
}
@@ -225,6 +225,8 @@ namespace Stary.Evo
command.Execute();
}
#region EnumEventSystem
private EnumEventSystem _mEnumEventSystem = new EnumEventSystem();
/// <summary>
@@ -384,6 +386,181 @@ namespace Stary.Evo
_mEnumEventSystem.UnRegister(key, onEvent);
}
#endregion
#region StringEventSystem
private StringEventSystem _mStringEventSystem = new StringEventSystem();
/// <summary>
/// 事件发送
/// </summary>
/// <typeparam name="T"></typeparam>
public void SendEvent(string key)
{
_mStringEventSystem.Send(key);
}
/// <summary>
/// 事件发送
/// </summary>
/// <typeparam name="T"></typeparam>
public void SendEvent<Tvalue1>(string key, Tvalue1 value) where Tvalue1 : class
{
_mStringEventSystem.Send(key, value);
}
/// <summary>
/// 事件发送
/// </summary>
/// <typeparam name="T"></typeparam>
public void SendEvent<Tvalue1, Tvalue2>(string key, Tvalue1 value1, Tvalue2 value2)
where Tvalue1 : class
where Tvalue2 : class
{
_mStringEventSystem.Send(key, value1, value2);
}
/// <summary>
/// 事件发送
/// </summary>
/// <typeparam name="T"></typeparam>
public void SendEvent<Tvalue1, Tvalue2, Tvalue3>(string key, Tvalue1 value1, Tvalue2 value2, Tvalue3 value3)
where Tvalue1 : class
where Tvalue2 : class
where Tvalue3 : class
{
_mStringEventSystem.Send(key, value1, value2, value3);
}
/// <summary>
/// 事件发送
/// </summary>
/// <typeparam name="T"></typeparam>
public void SendEvent(string key, object[] values)
{
_mStringEventSystem.Send(key, values);
}
/// <summary>
/// 事件监听
/// </summary>
/// <param name="onEvent"></param>
/// <typeparam name="T"></typeparam>
/// <returns></returns>
public IUnRegister RegisterEvent(string key, Action onEvent)
{
return _mStringEventSystem.Register(key, onEvent);
}
/// <summary>
/// 事件监听
/// </summary>
/// <param name="onEvent"></param>
/// <typeparam name="T"></typeparam>
/// <returns></returns>
public IUnRegister RegisterEvent<Tvalue1>(string key, Action<Tvalue1> onEvent)
where Tvalue1 : class
{
return _mStringEventSystem.Register(key, onEvent);
}
/// <summary>
/// 事件监听
/// </summary>
/// <param name="onEvent"></param>
/// <typeparam name="T"></typeparam>
/// <returns></returns>
public IUnRegister RegisterEvent<Tvalue1, Tvalue2>(string key, Action<Tvalue1, Tvalue2> onEvent)
where Tvalue1 : class
where Tvalue2 : class
{
return _mStringEventSystem.Register(key, onEvent);
}
/// <summary>
/// 事件监听
/// </summary>
/// <param name="onEvent"></param>
/// <typeparam name="T"></typeparam>
/// <returns></returns>
public IUnRegister RegisterEvent<Tvalue1, Tvalue2, Tvalue3>(string key, Action<Tvalue1, Tvalue2, Tvalue3> onEvent)
where Tvalue1 : class
where Tvalue2 : class
where Tvalue3 : class
{
return _mStringEventSystem.Register(key, onEvent);
}
/// <summary>
/// 事件监听
/// </summary>
/// <param name="onEvent"></param>
/// <typeparam name="T"></typeparam>
/// <returns></returns>
public IUnRegister RegisterEvent(string key, Action<object[]> onEvent)
{
return _mStringEventSystem.Register(key, onEvent);
}
/// <summary>
/// 事件销毁
/// </summary>
/// <param name="onEvent"></param>
/// <typeparam name="T"></typeparam>
public void UnRegisterEvent(string key, Action onEvent)
{
_mStringEventSystem.UnRegister(key, onEvent);
}
/// <summary>
/// 事件销毁
/// </summary>
/// <param name="onEvent"></param>
/// <typeparam name="T"></typeparam>
public void UnRegisterEvent<Tvalue1>(string key, Action<Tvalue1> onEvent)
where Tvalue1 : class
{
_mStringEventSystem.UnRegister(key, onEvent);
}
/// <summary>
/// 事件销毁
/// </summary>
/// <param name="onEvent"></param>
/// <typeparam name="T"></typeparam>
public void UnRegisterEvent<Tvalue1, Tvalue2>(string key, Action<Tvalue1, Tvalue2> onEvent)
where Tvalue1 : class
where Tvalue2 : class
{
_mStringEventSystem.UnRegister(key, onEvent);
}
/// <summary>
/// 事件销毁
/// </summary>
/// <param name="onEvent"></param>
/// <typeparam name="T"></typeparam>
public void UnRegisterEvent<Tvalue1, Tvalue2, Tvalue3>(string key, Action<Tvalue1, Tvalue2, Tvalue3> onEvent)
where Tvalue1 : class
where Tvalue2 : class
where Tvalue3 : class
{
_mStringEventSystem.UnRegister(key, onEvent);
}
/// <summary>
/// 事件销毁
/// </summary>
/// <param name="onEvent"></param>
/// <typeparam name="T"></typeparam>
public void UnRegisterEvent(string key, Action<object[]> onEvent)
{
_mStringEventSystem.UnRegister(key, onEvent);
}
#endregion
public TResult SendQuery<TResult>(IQuery<TResult> query)
{
return DoQuery<TResult>(query);

View File

@@ -168,6 +168,129 @@ namespace Stary.Evo
public void UnRegisterEvent<TEvent>(TEvent key, Action<object[]> onEvent) where TEvent : IConvertible;
/// <summary>
/// 事件发送
/// </summary>
/// <typeparam name="T"></typeparam>
public void SendEvent(string key);
/// <summary>
/// 事件发送
/// </summary>
/// <typeparam name="T"></typeparam>
public void SendEvent<Tvalue1>(string key, Tvalue1 value) where Tvalue1 : class;
/// <summary>
/// 事件发送
/// </summary>
/// <typeparam name="T"></typeparam>
public void SendEvent<Tvalue1, Tvalue2>(string key, Tvalue1 value1, Tvalue2 value2)
where Tvalue1 : class
where Tvalue2 : class;
/// <summary>
/// 事件发送
/// </summary>
/// <typeparam name="T"></typeparam>
public void SendEvent<Tvalue1, Tvalue2, Tvalue3>(string key, Tvalue1 value1, Tvalue2 value2, Tvalue3 value3)
where Tvalue1 : class
where Tvalue2 : class
where Tvalue3 : class;
/// <summary>
/// 事件发送
/// </summary>
/// <typeparam name="T"></typeparam>
public void SendEvent(string key, object[] values);
/// <summary>
/// 事件监听
/// </summary>
/// <param name="onEvent"></param>
/// <typeparam name="T"></typeparam>
/// <returns></returns>
public IUnRegister RegisterEvent(string key, Action onEvent);
/// <summary>
/// 事件监听
/// </summary>
/// <param name="onEvent"></param>
/// <typeparam name="T"></typeparam>
/// <returns></returns>
public IUnRegister RegisterEvent<Tvalue1>(string key, Action<Tvalue1> onEvent)
where Tvalue1 : class;
/// <summary>
/// 事件监听
/// </summary>
/// <param name="onEvent"></param>
/// <typeparam name="T"></typeparam>
/// <returns></returns>
public IUnRegister RegisterEvent<Tvalue1, Tvalue2>(string key, Action<Tvalue1, Tvalue2> onEvent)
where Tvalue1 : class
where Tvalue2 : class;
/// <summary>
/// 事件监听
/// </summary>
/// <param name="onEvent"></param>
/// <typeparam name="T"></typeparam>
/// <returns></returns>
public IUnRegister RegisterEvent<Tvalue1, Tvalue2, Tvalue3>(string key,
Action<Tvalue1, Tvalue2, Tvalue3> onEvent)
where Tvalue1 : class
where Tvalue2 : class
where Tvalue3 : class;
/// <summary>
/// 事件监听
/// </summary>
/// <param name="onEvent"></param>
/// <typeparam name="T"></typeparam>
/// <returns></returns>
public IUnRegister RegisterEvent(string key, Action<object[]> onEvent);
/// <summary>
/// 事件销毁
/// </summary>
/// <param name="onEvent"></param>
/// <typeparam name="T"></typeparam>
public void UnRegisterEvent(string key, Action onEvent);
/// <summary>
/// 事件销毁
/// </summary>
/// <param name="onEvent"></param>
/// <typeparam name="T"></typeparam>
public void UnRegisterEvent<Tvalue1>(string key, Action<Tvalue1> onEvent) where Tvalue1 : class;
/// <summary>
/// 事件销毁
/// </summary>
/// <param name="onEvent"></param>
/// <typeparam name="T"></typeparam>
public void UnRegisterEvent<Tvalue1, Tvalue2>(string key, Action<Tvalue1, Tvalue2> onEvent)
where Tvalue1 : class
where Tvalue2 : class;
/// <summary>
/// 事件销毁
/// </summary>
/// <param name="onEvent"></param>
/// <typeparam name="T"></typeparam>
public void UnRegisterEvent<Tvalue1, Tvalue2, Tvalue3>(string key, Action<Tvalue1, Tvalue2, Tvalue3> onEvent)
where Tvalue1 : class
where Tvalue2 : class
where Tvalue3 : class;
/// <summary>
/// 事件销毁
/// </summary>
/// <param name="onEvent"></param>
/// <typeparam name="T"></typeparam>
public void UnRegisterEvent(string key, Action<object[]> onEvent);
TResult SendQuery<TResult>(IQuery<TResult> query);
void OnDispose();

View File

@@ -3,30 +3,26 @@ using Sirenix.OdinInspector;
using UnityEditor;
using UnityEngine;
namespace Stary.Evo.Editor
namespace Stary.Evo
{
[CreateAssetMenu(fileName = "ArtSceneData", menuName = "Evo/ArtSceneData")]
public class ArtSceneData : ScriptableObject
{
[ListDrawerSettings(DraggableItems = false, ShowFoldout = false, ShowPaging = false, ShowItemCount = false)]
public List<ArtScene> artScenes = new List<ArtScene>();
}
[System.Serializable]
public class ArtScene
{
[LabelText("场景名称")]
public string sceneName;
#if UNITY_EDITOR
[LabelText("场景实例")][OnValueChanged("LoadScenePath")]
[LabelText("场景名称")] public string sceneName;
[LabelText("场景实例")] [OnValueChanged("LoadScenePath")]
public SceneAsset sceneAsset;
#endif
[LabelText("场景路径")][ReadOnly]
public string scenePath;
[LabelText("场景标识符")][ReadOnly]
public string sceneIdentifier;
[LabelText("场景路径")] [ReadOnly] public string scenePath;
[LabelText("场景标识符")] [ReadOnly] public string sceneIdentifier;
#if UNITY_EDITOR
public void LoadScenePath()
{
if (sceneAsset == null)
@@ -34,8 +30,13 @@ namespace Stary.Evo.Editor
Debug.LogError($"ArtScene {sceneName} 资源不存在,请检查!");
return;
}
scenePath = AssetDatabase.GetAssetPath(sceneAsset);
sceneIdentifier= $"Scenes_{sceneAsset.name}" ;
sceneIdentifier = $"Scenes_{sceneAsset.name}";
AssetDatabase.SaveAssets();
}
#endif
}
}

View File

@@ -27,9 +27,7 @@ namespace Stary.Evo
[Sirenix.OdinInspector.ReadOnly] public string className;
public LoadResType loadResType;
[Sirenix.OdinInspector.ReadOnly] [ShowIf("loadResType", LoadResType.Prefab)]
/// <summary>
@@ -38,18 +36,20 @@ namespace Stary.Evo
public string mainPrefab;
#if UNITY_EDITOR
[ShowIf("loadResType", LoadResType.Scene)][OnValueChanged("LoadScenePath")]
[ShowIf("loadResType", LoadResType.Scene)] [OnValueChanged("LoadScenePath")]
public SceneAsset sceneAsset;
#endif
[ShowIf("loadResType", LoadResType.Scene)][ReadOnly]
public string scenePath;
[ShowIf("loadResType", LoadResType.Scene)][ReadOnly]
public string sceneIdentifier;
[ShowIf("loadResType", LoadResType.Scene)]
[ShowIf("loadResType", LoadResType.Scene)]
public LoadSceneMode loadSceneMode;
[ShowIf("loadResType", LoadResType.Scene)] [ReadOnly]
public string scenePath;
[ShowIf("loadResType", LoadResType.Scene)] [ReadOnly]
public string sceneIdentifier;
#if UNITY_EDITOR
public void LoadScenePath()
{
if (sceneAsset == null)
@@ -57,14 +57,15 @@ namespace Stary.Evo
Debug.LogError($"Scene {scenePath} 资源不存在,请检查!");
return;
}
scenePath = AssetDatabase.GetAssetPath(sceneAsset);
sceneIdentifier= $"Scenes_{sceneAsset.name}" ;
sceneIdentifier = $"Scenes_{sceneAsset.name}";
}
#endif
public enum LoadResType
{
Prefab,
Scene
}
}
}

View File

@@ -2,66 +2,124 @@ using System;
namespace Stary.Evo
{
public interface ICanRegisterEvent:IBelongToArchitecture
public interface ICanRegisterEvent : IBelongToArchitecture
{
}
public static class CanRegisterEventExtension
{
public static IUnRegister RegisterEvent<T>(this ICanRegisterEvent self, T key, Action onEvent)
where T : IConvertible
{
return self.GetArchitecture().RegisterEvent(key, onEvent);
}
public static IUnRegister RegisterEvent<T>(this ICanRegisterEvent self,T key,Action onEvent) where T : IConvertible
public static IUnRegister RegisterEvent<T, T1>(this ICanRegisterEvent self, T key, Action<T1> onEvent)
where T : IConvertible
{
return self.GetArchitecture().RegisterEvent(key,onEvent);
return self.GetArchitecture().RegisterEvent(key, onEvent);
}
public static IUnRegister RegisterEvent<T,T1>(this ICanRegisterEvent self,T key,Action<T1> onEvent) where T : IConvertible
public static IUnRegister RegisterEvent<T, T1, T2>(this ICanRegisterEvent self, T key, Action<T1, T2> onEvent)
where T : IConvertible
{
return self.GetArchitecture().RegisterEvent(key,onEvent);
return self.GetArchitecture().RegisterEvent(key, onEvent);
}
public static IUnRegister RegisterEvent<T,T1,T2>(this ICanRegisterEvent self,T key,Action<T1,T2> onEvent) where T : IConvertible
public static IUnRegister RegisterEvent<T, T1, T2, T3>(this ICanRegisterEvent self, T key,
Action<T1, T2, T3> onEvent) where T : IConvertible
{
return self.GetArchitecture().RegisterEvent(key,onEvent);
return self.GetArchitecture().RegisterEvent(key, onEvent);
}
public static IUnRegister RegisterEvent<T,T1,T2,T3>(this ICanRegisterEvent self,T key,Action<T1,T2,T3> onEvent) where T : IConvertible
public static IUnRegister RegisterEvent<T>(this ICanRegisterEvent self, T key, Action<object[]> onEvent)
where T : IConvertible
{
return self.GetArchitecture().RegisterEvent(key,onEvent);
return self.GetArchitecture().RegisterEvent(key, onEvent);
}
public static IUnRegister RegisterEvent<T>(this ICanRegisterEvent self,T key,Action<object[]> onEvent) where T : IConvertible
public static void UnRegisterEvent<T>(this ICanRegisterEvent self, T key, Action onEvent) where T : IConvertible
{
return self.GetArchitecture().RegisterEvent(key,onEvent);
self.GetArchitecture().UnRegisterEvent(key, onEvent);
}
public static void UnRegisterEvent<T>(this ICanRegisterEvent self,T key,Action onEvent) where T : IConvertible
public static void UnRegisterEvent<T, T1>(this ICanRegisterEvent self, T key, Action<T1> onEvent)
where T : IConvertible
{
self.GetArchitecture().UnRegisterEvent(key,onEvent);
self.GetArchitecture().UnRegisterEvent(key, onEvent);
}
public static void UnRegisterEvent<T,T1>(this ICanRegisterEvent self,T key,Action<T1> onEvent) where T : IConvertible
public static void UnRegisterEvent<T, T1, T2>(this ICanRegisterEvent self, T key, Action<T1, T2> onEvent)
where T : IConvertible
{
self.GetArchitecture().UnRegisterEvent(key,onEvent);
self.GetArchitecture().UnRegisterEvent(key, onEvent);
}
public static void UnRegisterEvent<T,T1,T2>(this ICanRegisterEvent self,T key,Action<T1,T2> onEvent) where T : IConvertible
public static void UnRegisterEvent<T, T1, T2, T3>(this ICanRegisterEvent self, T key,
Action<T1, T2, T3> onEvent) where T : IConvertible
{
self.GetArchitecture().UnRegisterEvent(key,onEvent);
self.GetArchitecture().UnRegisterEvent(key, onEvent);
}
public static void UnRegisterEvent<T,T1,T2,T3>(this ICanRegisterEvent self,T key,Action<T1,T2,T3> onEvent) where T : IConvertible
public static void UnRegisterEvent<T>(this ICanRegisterEvent self, T key, Action<object[]> onEvent)
where T : IConvertible
{
self.GetArchitecture().UnRegisterEvent(key,onEvent);
self.GetArchitecture().UnRegisterEvent(key, onEvent);
}
public static void UnRegisterEvent<T>(this ICanRegisterEvent self,T key,Action<object[]> onEvent) where T : IConvertible
public static IUnRegister RegisterEvent(this ICanRegisterEvent self, string key, Action onEvent)
{
self.GetArchitecture().UnRegisterEvent(key,onEvent);
return self.GetArchitecture().RegisterEvent(key, onEvent);
}
public static IUnRegister RegisterEvent<T1>(this ICanRegisterEvent self, string key, Action<T1> onEvent)
{
return self.GetArchitecture().RegisterEvent(key, onEvent);
}
public static IUnRegister RegisterEvent<T1, T2>(this ICanRegisterEvent self, string key, Action<T1, T2> onEvent)
{
return self.GetArchitecture().RegisterEvent(key, onEvent);
}
public static IUnRegister RegisterEvent<T1, T2, T3>(this ICanRegisterEvent self, string key,
Action<T1, T2, T3> onEvent)
{
return self.GetArchitecture().RegisterEvent(key, onEvent);
}
public static IUnRegister RegisterEvent(this ICanRegisterEvent self, string key, Action<object[]> onEvent)
{
return self.GetArchitecture().RegisterEvent(key, onEvent);
}
public static void UnRegisterEvent(this ICanRegisterEvent self, string key, Action onEvent)
{
self.GetArchitecture().UnRegisterEvent(key, onEvent);
}
public static void UnRegisterEvent<T1>(this ICanRegisterEvent self, string key, Action<T1> onEvent)
{
self.GetArchitecture().UnRegisterEvent(key, onEvent);
}
public static void UnRegisterEvent<T1, T2>(this ICanRegisterEvent self, string key, Action<T1, T2> onEvent)
{
self.GetArchitecture().UnRegisterEvent(key, onEvent);
}
public static void UnRegisterEvent<T1, T2, T3>(this ICanRegisterEvent self, string key,
Action<T1, T2, T3> onEvent)
{
self.GetArchitecture().UnRegisterEvent(key, onEvent);
}
public static void UnRegisterEvent(this ICanRegisterEvent self, string key, Action<object[]> onEvent)
{
self.GetArchitecture().UnRegisterEvent(key, onEvent);
}
}
}

View File

@@ -3,7 +3,7 @@ using System.Collections.Generic;
namespace Stary.Evo
{
[Obsolete("推荐使用 EnumEventSystem",false)]
public class StringEventSystem
{
public static readonly StringEventSystem Global = new StringEventSystem();

View File

@@ -65,7 +65,7 @@ namespace Stary.Evo
await CurState.OnExitAsync();
FSMIStateAsync state = GetStateWithName(name);
CurState = state;
CurState.OnEnterAsync();
await CurState.OnEnterAsync();
}
/// <summary>

View File

@@ -106,7 +106,7 @@ namespace Stary.Evo
{
using UnityWebRequest webRequest =
new UnityWebRequest($"{url}?token={authorization}", UnityWebRequest.kHttpVerbGET);
new UnityWebRequest($"{url}/{authorization}", UnityWebRequest.kHttpVerbGET);
//using UnityWebRequest webRequest = UnityWebRequest.Get($"{url}?token={authorization}");
webRequest.downloadHandler = new DownloadHandlerBuffer();
webRequest.timeout = 10;
@@ -393,7 +393,7 @@ namespace Stary.Evo
webRequest.disposeUploadHandlerOnDispose = true;
webRequest.disposeDownloadHandlerOnDispose = true;
webRequest.disposeCertificateHandlerOnDispose = true;
webRequest.timeout = 20;
webRequest.timeout = 30;
await webRequest.SendWebRequest();
webRequest.uploadHandler?.Dispose();
// 更新错误检查方式

View File

@@ -11,12 +11,25 @@ namespace Stary.Evo
public string Platform { get; set; }
public string DocumentFileId { get; set; }
}
public struct ResDmainUpdateRequst
{
public string ProductName { get; set; }
public string DomainName { get; set; }
public string Platform { get; set; }
public bool IsEnabled { get; set; }
}
public struct ResDmainRequst
{
public string ProductName { get; set; }
public string DomainName { get; set; }
public string Platform { get; set; }
}
public struct ResProductRequst
{
public string ProductName { get; set; }
public string Platform { get; set; }
}
}

View File

@@ -1,8 +1,5 @@
namespace Stary.Evo
{
public struct ResDmainVersionResponse
{
public string ProductName { get; set; }
@@ -16,6 +13,7 @@ namespace Stary.Evo
public string ProductName { get; set; }
public string DomainName { get; set; }
public string Platform { get; set; }
public bool IsEnable { get; set; }
public string PackageVersion { get; set; }
public string DocumentFileId { get; set; }
}

View File

@@ -1,6 +1,6 @@
{
"name": "com.staryevo.main",
"version": "2.0.15",
"version": "2.0.16",
"displayName": "00.StaryEvo",
"description": "This is an Framework package(后台服务器版本端口9527)",
"unity": "2021.3",
@@ -15,7 +15,8 @@
"url": "http://192.168.31.100:8088/framework/xosmopluginlibrary.git#02.InformationSave"
},
"dependencies": {
"com.cysharp.unitask": "2.5.10"
"com.cysharp.unitask": "2.5.10",
"com.tuyoogame.yooasset": "2.3.16"
},
"samples": [
{

View File

@@ -0,0 +1,54 @@
using System;
using Sirenix.OdinInspector;
using UnityEngine;
namespace Stary.Evo.Editor
{
[Serializable]
public class BuildAssetEntity
{
public BuildAssetEntity(string HorizontalGroupName,string ButtonName ,Action OnClickAction )
{
this.HorizontalGroupName = HorizontalGroupName;
this.ButtonName = ButtonName;
this.OnClickAction = OnClickAction;
}
private Color messageColor = Color.white;
private string messageText = "点击开始进程!!!!!";
private bool showInfoBox = true;
private string HorizontalGroupName;
private string ButtonName;
private Action OnClickAction;
[HorizontalGroup("@ HorizontalGroupName")]
[Button("@ ButtonName", ButtonSizes.Large)]
[InfoBox("@ messageText", InfoMessageType.Error, "@ showInfoBox==false")]
[InfoBox("@ messageText", InfoMessageType.Info, "@ showInfoBox==true")]
private void CopyDll()
{
try
{
OnClickAction?.Invoke();
showInfoBox = true;
messageColor = Color.green;
messageText = "进程结束!!!!!";
}
catch (Exception e)
{
Debug.LogError(e);
showInfoBox = false;
messageText =$"进程存在异常,异常信息为:【{e.Message}】" ;
messageColor = Color.red;
}
}
public void SetButtonName(string ButtonName)
{
this.ButtonName = ButtonName;
}
}
}

View File

@@ -61,7 +61,7 @@ namespace Stary.Evo.Editor
protected override async void Initialize()
{
base.Initialize();
GetBuildPackageNames();
//初始化读取资源配置表
hotfixMainResDomain = Resources.Load<HotfixMainResDomain>("HotfixMainResDomain");
if (hotfixMainResDomain == null)
@@ -75,7 +75,7 @@ namespace Stary.Evo.Editor
userName = hotfixMainResDomain.hotfixMainResDomainEntity.username;
password = hotfixMainResDomain.hotfixMainResDomainEntity.password;
}
GetBuildPackageNames();
if (string.IsNullOrEmpty(ip))
{
buildAssetType = BuildAssetType.Login;

View File

@@ -16,7 +16,7 @@ namespace Stary.Evo.Editor
{
public class CreatAssetWindow : OdinEditorWindow
{
[MenuItem("Evo/Dev/创建Domain作用域",false, 1)]
[MenuItem("Evo/Dev/创建Domain作用域", false, 1)]
static void Init()
{
// Get existing open window or if none, make a new one:
@@ -71,6 +71,7 @@ namespace Stary.Evo.Editor
File.WriteAllTextAsync(
$"{artDomainPath}/这里放所有美术的资源,因涉及打包依赖等原因,不建议在上一层节点新增文件夹,如涉及文件夹规范等问题请@张铮.hint", "");
}
//创建Art 测试场景
/* 2. 再建 Scenes/Test */
string sceneDir = $"{artDomainPath}/Scenes/Test";
@@ -94,7 +95,7 @@ namespace Stary.Evo.Editor
var prefab = Resources.Load<GameObject>(prefabPath);
var spawned = (GameObject)PrefabUtility.InstantiatePrefab(prefab);
spawned.name = "RKCameraRig";
spawned.name = "RKCameraRigTest";
/* 6. 保存场景 */
string scenePath = Path.Combine("Assets/Art", name, "Scenes", "Test", "TestScene.unity");
@@ -140,7 +141,6 @@ namespace Stary.Evo.Editor
gameObj.name = domain;
CreatDirectory($"{resPath}/Prefabs");
string rootPfbFilePath = $"Assets/Domain/{domain}/AddressableRes/Prefabs/{domain}.prefab";
var localPath = AssetDatabase.GenerateUniqueAssetPath(rootPfbFilePath);
@@ -197,7 +197,6 @@ namespace Stary.Evo.Editor
AssetDatabase.LoadAssetAtPath<AssemblyDefinitionAsset>(configPath);
if (domain != "Main")
{
// 将程序集定义添加到 HybridCLR 热更列表
var settings = SettingsUtil.HybridCLRSettings;
if (!settings.hotUpdateAssemblyDefinitions.Contains(assemblyDefinitionAsset))
@@ -219,7 +218,6 @@ namespace Stary.Evo.Editor
HybridCLRSettings.Instance.hotUpdateAssemblyDefinitions = assemblies.ToArray();
HybridCLRSettings.Save();
}
#endif
AssetDatabase.SaveAssets();
@@ -242,7 +240,7 @@ namespace Stary.Evo.Editor
[TitleGroup("预览Domain作用域")]
[ListDrawerSettings(DraggableItems = false, ShowFoldout = false, ShowPaging = false, ShowItemCount = false,
HideRemoveButton = true,HideAddButton = true)]
HideRemoveButton = true, HideAddButton = true)]
public List<CreatDomainEntity> domainList;
protected override void Initialize()
@@ -326,6 +324,12 @@ namespace Stary.Evo.Editor
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文件夹

View File

@@ -0,0 +1,177 @@
using System;
using System.Collections.Generic;
using Sirenix.OdinInspector;
using Stary.Evo.Editor;
using UnityEditor;
using UnityEngine;
using YooAsset;
using YooAsset.Editor;
namespace Stary.Evo.Editor
{
[Serializable]
public class AbstractBuildPipelineViewer
{
//protected BuildAssetDataSetting dataSetting;
#region
public string packageName;
protected string selectedBuildPipelines;
public string packageVersion;
#endregion
// protected bool isSimulate;
// protected bool isRaw;
[Title("清理构建缓存", titleAlignment: TitleAlignments.Centered)]
[HorizontalGroup("BuildCache")]
[InfoBox("当不勾选此项的时候,引擎会开启增量打包模式,会极大提高构建速度!")]
[OnValueChanged("SetBuildCacheToggle")]
[HideIf("@ selectedBuildPipelines==EBuildPipeline.EditorSimulateBuildPipeline.ToString()")]
public bool clearBuildCacheToggle;
[Title("依赖数据库", titleAlignment: TitleAlignments.Centered)]
[HorizontalGroup("BuildCache")]
[InfoBox("当开启此项的时候,会极大提高构建速度!")]
[OnValueChanged("SetUseAssetDependencyDB")]
[HideIf("@ selectedBuildPipelines==EBuildPipeline.EditorSimulateBuildPipeline.ToString()")]
public bool useAssetDependencyDBToggle=true;
[Title("资源包的压缩方式", titleAlignment: TitleAlignments.Centered)]
[HorizontalGroup("BuildCache"), HideLabel]
[InfoBox("推荐LZ4压缩方式")]
[OnValueChanged("SetCompression")]
[HideIf("@ selectedBuildPipelines==EBuildPipeline.EditorSimulateBuildPipeline.ToString()")]
public ECompressOption compression = ECompressOption.LZ4;
// [Title("资源包文件名称样式", titleAlignment: TitleAlignments.Centered)]
// [HorizontalGroup("FileStyle"), HideLabel]
// [OnValueChanged("SetFileNameStyle")]
// [HideIf("@ dataSetting.selectedBuildPipelines==EBuildPipeline.EditorSimulateBuildPipeline")]
private EFileNameStyle fileNameStyle = EFileNameStyle.BundleName;
[Title("首包资源文件的拷贝方式", titleAlignment: TitleAlignments.Centered)]
[VerticalGroup("BuildCache/FileStyle"), HideLabel]
[InfoBox("资源拷贝方式是否拷贝StreamingAssets")]
[OnValueChanged("SetCopyBuildinFileOption")]
[HideIf("@ selectedBuildPipelines==EBuildPipeline.EditorSimulateBuildPipeline.ToString()")]
public EBuildinFileCopyOption copyBuildinFileOption = EBuildinFileCopyOption.ClearAndCopyAll;
[VerticalGroup("BuildCache/FileStyle"), HideLabel]
[OnValueChanged("SetCopyBuildinFileParams")]
[ShowIf(
"@copyBuildinFileOption==EBuildinFileCopyOption.ClearAndCopyByTags||copyBuildinFileOption==EBuildinFileCopyOption.OnlyCopyByTags ")]
public string copyBuildinFileParams;
public AbstractBuildPipelineViewer(string packageName,string selectedBuildPipelines,string packageVersion)
{
//this.dataSetting = dataSetting;
SetBuildPackageData(packageName,selectedBuildPipelines,packageVersion);
useAssetDependencyDBToggle = true;
SetUseAssetDependencyDB();
clearBuildCacheToggle = false;
SetBuildCacheToggle();
compression = ECompressOption.LZ4;
SetCompression();
fileNameStyle = EFileNameStyle.BundleName;
SetFileNameStyle();
copyBuildinFileOption = EBuildinFileCopyOption.ClearAndCopyAll;
SetCopyBuildinFileOption();
}
public void SetBuildPackageData(string packageName,string selectedBuildPipelines,string packageVersion)
{
this.packageName = packageName;
this.selectedBuildPipelines = selectedBuildPipelines;
this.packageVersion = packageVersion;
}
public void SetBuildPackagePackageName(string packageName)
{
this.packageName = packageName;
}
public void SetBuildPackagePackageVersion(string packageVersion)
{
this.packageVersion = packageVersion;
}
#region AssetBuild
private void SetCompression()
{
AssetBundleBuilderSetting.SetPackageCompressOption(packageName, selectedBuildPipelines,
compression);
}
private void SetFileNameStyle()
{
AssetBundleBuilderSetting.SetPackageFileNameStyle(packageName, selectedBuildPipelines,
fileNameStyle);
}
private void SetCopyBuildinFileOption()
{
AssetBundleBuilderSetting.SetPackageBuildinFileCopyOption(packageName,
selectedBuildPipelines, copyBuildinFileOption);
//PlayerPrefs.SetInt("CopyBuildinFileOption", (int)copyBuildinFileOption);
}
private void SetCopyBuildinFileParams()
{
AssetBundleBuilderSetting.SetPackageBuildinFileCopyParams(packageName,
selectedBuildPipelines, copyBuildinFileParams);
//PlayerPrefs.SetInt("CopyBuildinFileOption", (int)copyBuildinFileOption);
}
public void SetBuildCacheToggle()
{
AssetBundleBuilderSetting.SetPackageClearBuildCache(packageName, selectedBuildPipelines,
clearBuildCacheToggle);
}
public void SetUseAssetDependencyDB()
{
AssetBundleBuilderSetting.SetPackageUseAssetDependencyDB(packageName, selectedBuildPipelines,
useAssetDependencyDBToggle);
}
#endregion
public virtual void ExecuteBuild()
{
// GetPackageVersion();
// if (dataSetting.packageName == "Main")
// {
// dataSetting.GetBuildPackageVersion(true);
// }
}
/// <summary>
/// 创建加密类实例
/// </summary>
protected IEncryptionServices CreateEncryptionInstance()
{
var encyptionClassName =
AssetBundleBuilderSetting.GetPackageEncyptionServicesClassName(packageName,
selectedBuildPipelines);
var encryptionClassTypes = EditorTools.GetAssignableTypes(typeof(IEncryptionServices));
var classType = encryptionClassTypes.Find(x => x.FullName.Equals(encyptionClassName));
if (classType != null)
return (IEncryptionServices)Activator.CreateInstance(classType);
else
return null;
}
}
}

View File

@@ -0,0 +1,70 @@
using System;
using UnityEditor;
using UnityEngine;
using YooAsset;
using YooAsset.Editor;
namespace Stary.Evo.Editor
{
[Serializable]
public class ScriptableBuildPipelineViewer:AbstractBuildPipelineViewer
{
public ScriptableBuildPipelineViewer(string packageName, string selectedBuildPipelines, string packageVersion) :
base(packageName, selectedBuildPipelines, packageVersion)
{
//isSimulate = false;
}
public override void ExecuteBuild()
{
var fileNameStyle = AssetBundleBuilderSetting.GetPackageFileNameStyle(packageName, selectedBuildPipelines);
var buildinFileCopyOption = AssetBundleBuilderSetting.GetPackageBuildinFileCopyOption(packageName, selectedBuildPipelines);
var buildinFileCopyParams = AssetBundleBuilderSetting.GetPackageBuildinFileCopyParams(packageName, selectedBuildPipelines);
var compressOption = AssetBundleBuilderSetting.GetPackageCompressOption(packageName, selectedBuildPipelines);
var clearBuildCache = AssetBundleBuilderSetting.GetPackageClearBuildCache(packageName, selectedBuildPipelines);
var useAssetDependencyDB = AssetBundleBuilderSetting.GetPackageUseAssetDependencyDB(packageName, selectedBuildPipelines);
var builtinShaderBundleName = GetBuiltinShaderBundleName();
ScriptableBuildParameters buildParameters = new ScriptableBuildParameters();
buildParameters.BuildOutputRoot = AssetBundleBuilderHelper.GetDefaultBuildOutputRoot();
buildParameters.BuildinFileRoot = AssetBundleBuilderHelper.GetStreamingAssetsRoot();
buildParameters.BuildPipeline = selectedBuildPipelines;
buildParameters.BuildBundleType = (int)EBuildBundleType.AssetBundle;
buildParameters.BuildTarget = EditorUserBuildSettings.activeBuildTarget;
buildParameters.PackageName = packageName;
buildParameters.PackageVersion = packageVersion;
buildParameters.EnableSharePackRule = true;
buildParameters.VerifyBuildingResult = true;
buildParameters.FileNameStyle = fileNameStyle;
buildParameters.BuildinFileCopyOption = buildinFileCopyOption;
buildParameters.BuildinFileCopyParams = buildinFileCopyParams;
buildParameters.CompressOption = compressOption;
buildParameters.ClearBuildCacheFiles = clearBuildCache;
buildParameters.UseAssetDependencyDB = useAssetDependencyDB;
buildParameters.BuiltinShadersBundleName = builtinShaderBundleName;
buildParameters.EncryptionServices = CreateEncryptionInstance();
ScriptableBuildPipeline pipeline = new ScriptableBuildPipeline();
var buildResult = pipeline.Run(buildParameters, true);
if (buildResult.Success)
{
Debug.Log($"Build Success! 【{buildResult.OutputPackageDirectory}】");
// EditorUtility.RevealInFinder(buildResult.OutputPackageDirectory);
base.ExecuteBuild();
}
}
/// <summary>
/// 内置着色器资源包名称
/// 注意:和自动收集的着色器资源包名保持一致!
/// </summary>
private string GetBuiltinShaderBundleName()
{
var uniqueBundleName = AssetBundleCollectorSettingData.Setting.UniqueBundleName;
var packRuleResult = DefaultPackRule.CreateShadersPackRuleResult();
return packRuleResult.GetBundleName(packageName, uniqueBundleName);
}
}
}

View File

@@ -11,67 +11,84 @@ namespace Stary.Evo
/// <summary>
/// 序列化属性在OnEnable中获取
/// </summary>
[HideInInspector]
private SerializedProperty domain;
[HideInInspector] private SerializedProperty domain;
private SerializedProperty stage;
/// <summary>
/// 序列化属性在OnEnable中获取
/// </summary>
[HideInInspector]
private SerializedProperty loadDomain;
[HideInInspector] private SerializedProperty loadDomain;
private string[] domainNames;
private string[] artNames;
private string[] loadDomainNames;
private void OnEnable()
private async void OnEnable()
{
domain = serializedObject.FindProperty("domain");
loadDomain = serializedObject.FindProperty("loadDomain");
stage = serializedObject.FindProperty("stage");
domainNames = CreatAssetWindow.GetCreatDomainAllName();
artNames = await ArtLoadAssetServer.GetServerDomainAllName();
// 创建新数组,长度+1并在第0位插入null
// 创建新数组,长度+1并在第0位插入null
loadDomainNames = new string[domainNames.Length + 1];
loadDomainNames[0]="null"; // 第0位添加null
loadDomainNames[0] = "null"; // 第0位添加null
Array.Copy(domainNames, 0, loadDomainNames, 1, domainNames.Length); // 复制原始元素到新数组从索引1开始
}
public override void OnInspectorGUI()
{
serializedObject.Update();
// 获取当前选中的索引
int selectedIndex = System.Array.IndexOf(domainNames, domain.stringValue);
if (selectedIndex < 0) selectedIndex = 0; // 默认选中第一个
// 绘制下拉选择框
selectedIndex = EditorGUILayout.Popup("Domain", selectedIndex, domainNames);
// 更新选择的域名
domain.stringValue = domainNames[selectedIndex];
EditorGUILayout.PropertyField(stage, new GUIContent("Stage"));
// 在 HybridClREntranceEditor 类的 OnInspectorGUI 方法中
StageType currentStage = (StageType)stage.enumValueIndex;
EditorGUILayout.Space();
string[] current = currentStage == StageType.Developer ? domainNames : artNames;
if (current != null && current.Length > 0)
{
// 获取当前选中的索引
int selectedIndex = System.Array.IndexOf(current, domain.stringValue);
if (selectedIndex < 0) selectedIndex = 0; // 默认选中第一个
// 绘制下拉选择框
selectedIndex = EditorGUILayout.Popup("Domain", selectedIndex, current);
// 更新选择的域名
domain.stringValue = current[selectedIndex];
}
HybridClREntrance hybridClREntrance = target as HybridClREntrance;
if (GUILayout.Button("打开Domain"))
{
hybridClREntrance.OpenDomain();
}
if (GUILayout.Button("关闭Domain"))
{
hybridClREntrance.CloseDomain();
}
//loaddoamin绘制
// 获取当前选中的索引
int loadDomainSelectedIndex = System.Array.IndexOf(loadDomainNames, loadDomain.stringValue);
if (loadDomainSelectedIndex < 0) loadDomainSelectedIndex = 0; // 默认选中第一个
// 绘制下拉选择框
loadDomainSelectedIndex = EditorGUILayout.Popup("LoadDomain", loadDomainSelectedIndex, loadDomainNames);
// 更新选择的域名
loadDomain.stringValue = loadDomainNames[loadDomainSelectedIndex];
if (currentStage == StageType.Developer)
{
int loadDomainSelectedIndex = System.Array.IndexOf(loadDomainNames, loadDomain.stringValue);
if (loadDomainSelectedIndex < 0) loadDomainSelectedIndex = 0; // 默认选中第一个
// 绘制下拉选择框
loadDomainSelectedIndex = EditorGUILayout.Popup("LoadDomain", loadDomainSelectedIndex, loadDomainNames);
// 更新选择的域名
loadDomain.stringValue = loadDomainNames[loadDomainSelectedIndex];
}
serializedObject.ApplyModifiedProperties();
}
}

View File

@@ -14,7 +14,7 @@ using YooAsset.Editor;
namespace Stary.Evo.Editor
{
public class MarkAdressable : MonoBehaviour
public class MarkAdressable
{
private static AssetBundleCollectorPackage package;
private static string _packageName;
@@ -210,8 +210,8 @@ namespace Stary.Evo.Editor
// [MenuItem("Evo/Hotfix/一键Res")]
public static void CreateRes(string domain, string resPath, string outputPath)
{
FileGet.CreateClass("Res", domain, outputPath,
(a) => { FileGet.CreateContent(a, resPath, "\t"); });
ResFileGet.CreateClass("Res", domain, outputPath,
(a) => { ResFileGet.CreateContent(a, resPath, "\t"); });
}
#region
@@ -247,7 +247,7 @@ namespace Stary.Evo.Editor
{
string groupName = info.Name;
if (info.Name == "Scenes")
if (info.Name == "Scenes"||info.Name == "Config")
{
AssetBundleCollectorGroup collectorGroup =
YooAsset.Editor.AssetBundleCollectorSettingData.CreateGroup(package, groupName);
@@ -261,7 +261,6 @@ namespace Stary.Evo.Editor
Debug.LogError("分组 " + groupName + "已存在,请检查资源目录,避免重复");
}
AutoMarkRootAddress(info);
break;
}
}
// AssetDatabase.SaveAssets();

View File

@@ -9,7 +9,7 @@ using UnityEngine;
namespace Stary.Evo.Editor
{
public static class FileGet
public static class ResFileGet
{
public static void CreateContent(StringBuilder variable, string path, string tab)
{

Some files were not shown because too many files have changed in this diff Show More