【m】build apk 开发
This commit is contained in:
33
Assets/00.StaryEvo/Editor/Build/BuildApkEntity.cs
Normal file
33
Assets/00.StaryEvo/Editor/Build/BuildApkEntity.cs
Normal file
@@ -0,0 +1,33 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Sirenix.OdinInspector;
|
||||
using Sirenix.OdinInspector.Editor;
|
||||
using UnityEditor;
|
||||
using UnityEditor.Build.Reporting;
|
||||
using UnityEngine;
|
||||
|
||||
[Serializable]
|
||||
public class BuildApkEntity
|
||||
{
|
||||
public BuildApkEntity(Action OnBuildApkAction, Action OnBuildApkUpdateAction)
|
||||
{
|
||||
this._onBuildApkAction = OnBuildApkAction;
|
||||
this._onBuildApkUpdateAction = OnBuildApkUpdateAction;
|
||||
}
|
||||
|
||||
|
||||
private Action _onBuildApkAction;
|
||||
private Action _onBuildApkUpdateAction;
|
||||
|
||||
[Button("打包", ButtonSizes.Large)]
|
||||
private void BuildApk()
|
||||
{
|
||||
this._onBuildApkAction?.Invoke();
|
||||
}
|
||||
|
||||
[Button("上传服务器", ButtonSizes.Large)]
|
||||
private void BuildApkUpdate()
|
||||
{
|
||||
this._onBuildApkUpdateAction?.Invoke();
|
||||
}
|
||||
}
|
||||
3
Assets/00.StaryEvo/Editor/Build/BuildApkEntity.cs.meta
Normal file
3
Assets/00.StaryEvo/Editor/Build/BuildApkEntity.cs.meta
Normal file
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 9d2f8d70d3b1414a934ca1b195d13b9c
|
||||
timeCreated: 1751429102
|
||||
126
Assets/00.StaryEvo/Editor/Build/BuildApkWindow.cs
Normal file
126
Assets/00.StaryEvo/Editor/Build/BuildApkWindow.cs
Normal file
@@ -0,0 +1,126 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Sirenix.OdinInspector;
|
||||
using Sirenix.OdinInspector.Editor;
|
||||
using Stary.Evo;
|
||||
using UnityEditor;
|
||||
using UnityEditor.Build.Reporting;
|
||||
using UnityEngine;
|
||||
using BuildReport = UnityEditor.Build.Reporting.BuildReport;
|
||||
|
||||
public class BuildApkWindow : OdinEditorWindow
|
||||
{
|
||||
public static OdinEditorWindow window;
|
||||
|
||||
[MenuItem("Evo/Apk打包工具")]
|
||||
static void ShowWindows()
|
||||
{
|
||||
window = (BuildApkWindow)EditorWindow.GetWindow(typeof(BuildApkWindow));
|
||||
window.maxSize = new Vector2(400, 500);
|
||||
window.Show();
|
||||
}
|
||||
|
||||
protected override void Initialize()
|
||||
{
|
||||
base.Initialize();
|
||||
buildApkLocalEntity = new BuildApkEntity(BuildAndroid, BuildAndroid);
|
||||
buildApkServerEntity = new BuildApkEntity(BuildAndroid, BuildAndroid);
|
||||
buildApkWatermarkEntity = new BuildApkEntity(BuildAndroid, BuildAndroid);
|
||||
}
|
||||
|
||||
[EnumToggleButtons, HideLabel] public DeviceType deviceType;
|
||||
|
||||
[BoxGroup("Build(清空打包缓存)", centerLabel: true, order: 1)]
|
||||
[Button("清空打包缓存")]
|
||||
void OnClearCache()
|
||||
{
|
||||
// 清理Library缓存目录
|
||||
// 使用System.IO删除
|
||||
// try {
|
||||
// System.IO.Directory.Delete(Application.dataPath + "/../Library/AssetImportState", true);
|
||||
// Debug.Log("成功删除AssetImportState");
|
||||
// } catch (System.Exception e) {
|
||||
// Debug.LogError($"删除失败: {e.Message}");
|
||||
// }
|
||||
// 使用System.IO删除
|
||||
try
|
||||
{
|
||||
System.IO.Directory.Delete(Application.dataPath + "/../Library/BuildCache", true);
|
||||
Debug.Log("成功删除BuildCache");
|
||||
}
|
||||
catch (System.Exception e)
|
||||
{
|
||||
Debug.LogError($"删除失败: {e.Message}");
|
||||
}
|
||||
|
||||
// 使用System.IO删除
|
||||
try
|
||||
{
|
||||
System.IO.Directory.Delete(Application.dataPath + "/../Library/ScriptAssemblies", true);
|
||||
Debug.Log("成功删除ScriptAssemblies");
|
||||
}
|
||||
catch (System.Exception e)
|
||||
{
|
||||
Debug.LogError($"删除失败: {e.Message}");
|
||||
}
|
||||
|
||||
AssetDatabase.Refresh();
|
||||
EditorUtility.DisplayDialog("缓存清理", "已成功清除所有打包缓存文件", "确定");
|
||||
}
|
||||
|
||||
[BoxGroup("Build(普通包\\服务器本地包)", centerLabel: true, order: 2), HideLabel]
|
||||
public BuildApkEntity buildApkLocalEntity;
|
||||
|
||||
[BoxGroup("Build(服务器热更包)", centerLabel: true, order: 3), HideLabel]
|
||||
public BuildApkEntity buildApkServerEntity;
|
||||
|
||||
[BoxGroup("Build(水印包)", centerLabel: true, order: 4), HideLabel]
|
||||
public BuildApkEntity buildApkWatermarkEntity;
|
||||
|
||||
public void BuildAndroid()
|
||||
{
|
||||
HotfixMainResDomain hotfixMainResDomain = Resources.Load<HotfixMainResDomain>("HotfixMainResDomain");
|
||||
if (hotfixMainResDomain == null)
|
||||
{
|
||||
Debug.LogError("HotfixMainResDomain 资源在Resources下不存在,请检查!");
|
||||
}
|
||||
|
||||
// 设置包名和项目名
|
||||
PlayerSettings.productName = hotfixMainResDomain.projectInfo.projectName;
|
||||
PlayerSettings.applicationIdentifier = hotfixMainResDomain.projectInfo.projectPackageName;
|
||||
|
||||
// 配置构建选项
|
||||
BuildPlayerOptions buildOptions = new BuildPlayerOptions
|
||||
{
|
||||
scenes = new[]
|
||||
{
|
||||
$"Assets/SplashScreen/EvoScenes/loading.unity",
|
||||
$"Assets/Main/main_{deviceType.ToString()}.unity"
|
||||
},
|
||||
locationPathName = $"Builds/Android/{PlayerSettings.applicationIdentifier}.apk",
|
||||
target = BuildTarget.Android,
|
||||
options = BuildOptions.None
|
||||
};
|
||||
|
||||
// 执行打包
|
||||
BuildReport report = BuildPipeline.BuildPlayer(buildOptions);
|
||||
|
||||
BuildSummary summary = report.summary;
|
||||
if (summary.result == BuildResult.Succeeded)
|
||||
{
|
||||
Debug.Log("Build succeeded: " + summary.totalSize + " bytes");
|
||||
}
|
||||
|
||||
if (summary.result == BuildResult.Failed)
|
||||
{
|
||||
Debug.LogError("Build failed");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public enum DeviceType
|
||||
{
|
||||
Xreal,
|
||||
Rokid
|
||||
}
|
||||
}
|
||||
11
Assets/00.StaryEvo/Editor/Build/BuildApkWindow.cs.meta
Normal file
11
Assets/00.StaryEvo/Editor/Build/BuildApkWindow.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 81361a51e315e2345b51e3004941d04a
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -10,19 +10,17 @@ using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.IO.Compression;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using EditorFramework;
|
||||
#if HotUpdate
|
||||
using HybridCLR.Editor;
|
||||
using HybridCLR.Editor.Commands;
|
||||
#endif
|
||||
using Newtonsoft.Json;
|
||||
using Newtonsoft.Json.Linq;
|
||||
using Sirenix.OdinInspector;
|
||||
using Sirenix.OdinInspector.Editor;
|
||||
using UnityEditor;
|
||||
using UnityEditorInternal;
|
||||
using UnityEngine;
|
||||
using UnityEngine.Serialization;
|
||||
using YooAsset;
|
||||
using YooAsset.Editor;
|
||||
|
||||
@@ -36,6 +34,18 @@ namespace Stary.Evo.Editor
|
||||
[MenuItem("Evo/资源打包工具")]
|
||||
static void ShowWindows()
|
||||
{
|
||||
#if NotUpdate
|
||||
|
||||
#elif HotUpdate
|
||||
#endif
|
||||
|
||||
#if NotUpdate
|
||||
if (EditorUtility.DisplayDialog("提示", "当前为非热更模式,不支持热更打包功能,是否切换热更模式", "是", "否"))
|
||||
{
|
||||
ChangeHotUpdateSchema.SetHotUpdateMode(HotUpdateMode.HotUpdate);
|
||||
}
|
||||
|
||||
#elif HotUpdate
|
||||
if (CreatAssetWindow.GetCreatDomainAll().Count <= 0)
|
||||
{
|
||||
EditorUtility.DisplayDialog("提示", "不存在Domain元素,无法打开此面板,请先创建Domain元素", "确定");
|
||||
@@ -44,6 +54,7 @@ namespace Stary.Evo.Editor
|
||||
|
||||
window = (BuildAssetWindow)EditorWindow.GetWindow(typeof(BuildAssetWindow));
|
||||
window.Show();
|
||||
#endif
|
||||
}
|
||||
|
||||
protected override void OnDisable()
|
||||
@@ -86,7 +97,7 @@ namespace Stary.Evo.Editor
|
||||
|
||||
[ShowIf("@ buildAssetType== BuildAssetType.Login")] [BoxGroup("Login", showLabel: false)]
|
||||
public string ip, userName, password;
|
||||
|
||||
|
||||
[ShowIf("@ buildAssetType== BuildAssetType.Login")]
|
||||
[BoxGroup("Login", showLabel: false)]
|
||||
[Button("登录", ButtonSizes.Large)]
|
||||
@@ -167,8 +178,10 @@ namespace Stary.Evo.Editor
|
||||
public BuildAssetEntity hyBridClrBuildEntity =
|
||||
new BuildAssetEntity("HyBridCLRBuild", "DllBuildTarget", () =>
|
||||
{
|
||||
#if HotUpdate
|
||||
//PrebuildCommand.GenerateAll();
|
||||
CompileDllCommand.CompileDllActiveBuildTarget();
|
||||
#endif
|
||||
});
|
||||
|
||||
#endregion
|
||||
@@ -380,6 +393,7 @@ namespace Stary.Evo.Editor
|
||||
Debug.LogError($"UnityEvo:读取资源配置表失败【HotfixMainResDomain】...表不存在");
|
||||
return;
|
||||
}
|
||||
|
||||
var ip = hotfixMainResDomain.hotfixMainResDomainEntity.ipconfig;
|
||||
var messageEntity = await WebRequestSystem.PostFile(ip + "/FileLoad/UpLoadFile", new[] { zipFilePath });
|
||||
EditorUtility.DisplayProgressBar("提示", $"开始上传{setting.packageName}(上传zip文件)", 0.5f);
|
||||
|
||||
@@ -0,0 +1,78 @@
|
||||
using System;
|
||||
using System.Linq;
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Stary.Evo.Editor
|
||||
{
|
||||
public class ChangeHotUpdateSchema
|
||||
{
|
||||
public static HotUpdateMode HotUpdateMode
|
||||
{
|
||||
get => _hotUpdate;
|
||||
set => SetHotUpdateMode(value);
|
||||
}
|
||||
|
||||
private static HotUpdateMode _hotUpdate;
|
||||
|
||||
private const string EditorNotUpdateMode = "Evo/ChangeHotUpdateSchema/NOTUPDARE(非热更模式)";
|
||||
private const string EditorHotUpdateMode = "Evo/ChangeHotUpdateSchema/HOTUPDATE(热更模式)";
|
||||
|
||||
[MenuItem(EditorNotUpdateMode)]
|
||||
private static void SetNotUpdateMode() => SetHotUpdateMode(HotUpdateMode.NotUpdate);
|
||||
|
||||
[MenuItem(EditorHotUpdateMode)]
|
||||
private static void SetHotUpdateMode() => SetHotUpdateMode(HotUpdateMode.HotUpdate);
|
||||
|
||||
// [MenuItem(WebPlayMode)]
|
||||
// private static void SetWebMode() => SetPlayerMode(HotUpdateMode.WEB_PLAYMODE);
|
||||
|
||||
[MenuItem(EditorNotUpdateMode, true)]
|
||||
private static bool ValidateModeMenu()
|
||||
{
|
||||
string platform = EditorPrefs.GetString("ChangeHotUpdateSchema");
|
||||
Menu.SetChecked(EditorNotUpdateMode, platform == HotUpdateMode.NotUpdate.ToString());
|
||||
Menu.SetChecked(EditorHotUpdateMode, platform == HotUpdateMode.HotUpdate.ToString());
|
||||
//Menu.SetChecked(WebPlayMode, platform == HotUpdateMode.WEB_PLAYMODE.ToString());
|
||||
Debug.LogError("ChangeHotUpdateSchema");
|
||||
return true;
|
||||
}
|
||||
|
||||
public static void SetHotUpdateMode(HotUpdateMode mode)
|
||||
{
|
||||
// 清除所有旧模式定义
|
||||
var currentTarget = EditorUserBuildSettings.selectedBuildTargetGroup;
|
||||
if (currentTarget == BuildTargetGroup.Unknown) return;
|
||||
|
||||
var defines = PlayerSettings.GetScriptingDefineSymbolsForGroup(currentTarget)
|
||||
.Split(';')
|
||||
.Where(d => !Enum.GetNames(typeof(HotUpdateMode)).Contains(d))
|
||||
.ToList();
|
||||
|
||||
// 添加新模式
|
||||
defines.Add(mode.ToString());
|
||||
PlayerSettings.SetScriptingDefineSymbolsForGroup(currentTarget, string.Join(";", defines));
|
||||
Debug.Log($"当前编译符号: {string.Join(";", defines)}"); // 添加调试日志
|
||||
_hotUpdate = mode;
|
||||
EditorPrefs.SetString("ChangeHotUpdateSchema", _hotUpdate.ToString());
|
||||
|
||||
ValidateModeMenu();
|
||||
AssetDatabase.Refresh();
|
||||
// 添加解决方案文件重新生成逻辑
|
||||
EditorApplication.delayCall += () =>
|
||||
{
|
||||
EditorApplication.ExecuteMenuItem("Assets/Open C# Project");
|
||||
UnityEditor.Compilation.CompilationPipeline.RequestScriptCompilation();
|
||||
Debug.Log("已强制重新生成解决方案文件");
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
public enum HotUpdateMode
|
||||
{
|
||||
//非热更模式,
|
||||
NotUpdate,
|
||||
//热更模式
|
||||
HotUpdate,
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 7d18419d2d9c488687f9aff50cbd8357
|
||||
timeCreated: 1751423025
|
||||
@@ -5,7 +5,7 @@ using UnityEngine;
|
||||
|
||||
namespace Stary.Evo.Editor
|
||||
{
|
||||
public class ChangePlayerMode
|
||||
public class ChangePlayerSchema
|
||||
{
|
||||
public static PLayerMode PLayerMode
|
||||
{
|
||||
@@ -15,10 +15,10 @@ namespace Stary.Evo.Editor
|
||||
|
||||
private static PLayerMode _pLayerMode;
|
||||
|
||||
private const string EditorSimulateMode = "Evo/ChangePlayerMode/EditorSimulateMode(编辑器调试模式)";
|
||||
private const string OfflinePlayMode = "Evo/ChangePlayerMode/OfflinePlayMode(本地运行模式)";
|
||||
private const string HostPlayMode = "Evo/ChangePlayerMode/HostPlayMode(服务器运行模式)";
|
||||
private const string WebPlayMode = "Evo/ChangePlayerMode/WebPlayMode(Web运行模式)";
|
||||
private const string EditorSimulateMode = "Evo/ChangePlayerSchema/EditorSimulateMode(编辑器调试模式)";
|
||||
private const string OfflinePlayMode = "Evo/ChangePlayerSchema/OfflinePlayMode(本地运行模式)";
|
||||
private const string HostPlayMode = "Evo/ChangePlayerSchema/HostPlayMode(服务器运行模式)";
|
||||
private const string WebPlayMode = "Evo/ChangePlayerSchema/WebPlayMode(Web运行模式)";
|
||||
|
||||
[MenuItem(EditorSimulateMode)]
|
||||
private static void SetEditorMode() => SetPlayerMode(PLayerMode.EDITOR_SIMULATEMODE);
|
||||
@@ -29,22 +29,22 @@ namespace Stary.Evo.Editor
|
||||
[MenuItem(HostPlayMode)]
|
||||
private static void SetHostMode() => SetPlayerMode(PLayerMode.HOST_PLAYMODE);
|
||||
|
||||
[MenuItem(WebPlayMode)]
|
||||
private static void SetWebMode() => SetPlayerMode(PLayerMode.WEB_PLAYMODE);
|
||||
// [MenuItem(WebPlayMode)]
|
||||
// private static void SetWebMode() => SetPlayerMode(PLayerMode.WEB_PLAYMODE);
|
||||
|
||||
[MenuItem(EditorSimulateMode, true)]
|
||||
private static bool ValidateModeMenu()
|
||||
{
|
||||
string platform = EditorPrefs.GetString("ChangePLayerMode", PLayerMode.EDITOR_SIMULATEMODE.ToString());
|
||||
string platform = EditorPrefs.GetString("ChangePlayerSchema");
|
||||
Menu.SetChecked(EditorSimulateMode, platform == PLayerMode.EDITOR_SIMULATEMODE.ToString());
|
||||
Menu.SetChecked(OfflinePlayMode, platform == PLayerMode.OFFLINE_PLAYMODE.ToString());
|
||||
Menu.SetChecked(HostPlayMode, platform == PLayerMode.HOST_PLAYMODE.ToString());
|
||||
Menu.SetChecked(WebPlayMode, platform == PLayerMode.WEB_PLAYMODE.ToString());
|
||||
//Menu.SetChecked(WebPlayMode, platform == PLayerMode.WEB_PLAYMODE.ToString());
|
||||
Debug.LogError("CheckPlatform");
|
||||
return true;
|
||||
}
|
||||
|
||||
private static void SetPlayerMode(PLayerMode mode)
|
||||
public static void SetPlayerMode(PLayerMode mode)
|
||||
{
|
||||
// 清除所有旧模式定义
|
||||
var currentTarget = EditorUserBuildSettings.selectedBuildTargetGroup;
|
||||
@@ -60,7 +60,8 @@ namespace Stary.Evo.Editor
|
||||
PlayerSettings.SetScriptingDefineSymbolsForGroup(currentTarget, string.Join(";", defines));
|
||||
Debug.Log($"当前编译符号: {string.Join(";", defines)}"); // 添加调试日志
|
||||
_pLayerMode = mode;
|
||||
EditorPrefs.SetString("ChangePLayerMode", _pLayerMode.ToString());
|
||||
EditorPrefs.SetString("ChangePlayerSchema", _pLayerMode.ToString());
|
||||
ValidateModeMenu();
|
||||
AssetDatabase.Refresh();
|
||||
// 添加解决方案文件重新生成逻辑
|
||||
EditorApplication.delayCall += () =>
|
||||
@@ -83,7 +84,7 @@ namespace Stary.Evo.Editor
|
||||
//联机运行模式
|
||||
HOST_PLAYMODE,
|
||||
|
||||
//web运行模式
|
||||
WEB_PLAYMODE
|
||||
// //web运行模式
|
||||
// WEB_PLAYMODE
|
||||
}
|
||||
}
|
||||
@@ -2,8 +2,10 @@ 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 Stary.Evo.InformationSave;
|
||||
@@ -13,7 +15,6 @@ using UnityEngine;
|
||||
|
||||
namespace Stary.Evo.Editor
|
||||
{
|
||||
|
||||
public class CreatAssetWindow : OdinEditorWindow
|
||||
{
|
||||
[MenuItem("Evo/创建Domain作用域")]
|
||||
@@ -48,8 +49,8 @@ namespace Stary.Evo.Editor
|
||||
Directory.CreateDirectory(artDomainPath);
|
||||
|
||||
if (!Directory.Exists(artDomainPath))
|
||||
//创建Animation文件夹
|
||||
CreatDirectory(artDomainPath + "/Animation");
|
||||
//创建Animation文件夹
|
||||
CreatDirectory(artDomainPath + "/Animation");
|
||||
//创建Effects文件夹
|
||||
CreatDirectory(artDomainPath + "/Effects");
|
||||
//创建Fbx文件夹
|
||||
@@ -115,9 +116,8 @@ namespace Stary.Evo.Editor
|
||||
transformInfo.transform.position = Vector3.zero;
|
||||
transformInfo.transform.rotation = Quaternion.identity;
|
||||
transformInfo.AddComponent<LocalTransformInfo>();
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
CreatDirectory($"{resPath}/Prefabs");
|
||||
string rootPfbFilePath = $"Assets/Domain/{domain}/AddressableRes/Prefabs/{domain}.prefab";
|
||||
var localPath = AssetDatabase.GenerateUniqueAssetPath(rootPfbFilePath);
|
||||
@@ -145,11 +145,11 @@ namespace Stary.Evo.Editor
|
||||
body = body.Replace("ROOT_NAMESPACE", hotfixDomain);
|
||||
await writer.WriteAsync(body);
|
||||
}
|
||||
|
||||
|
||||
//模块化脚本生成配置
|
||||
string domainClassName = $"{domain}Domain";
|
||||
string architectureClassName = $"{domain}Architecture";
|
||||
|
||||
#if HotUpdate
|
||||
//模块配置资源
|
||||
DomainConfig moduleConfig = CreateInstance<DomainConfig>();
|
||||
moduleConfig.domain = domain;
|
||||
@@ -158,7 +158,7 @@ namespace Stary.Evo.Editor
|
||||
moduleConfig.@namespace = domain;
|
||||
AssetDatabase.CreateAsset(moduleConfig, $"Assets/Domain/{domain}/AddressableRes/Config/DomainConfig.asset");
|
||||
//
|
||||
|
||||
|
||||
|
||||
//编辑器配置资源
|
||||
BuildAssetDataSetting buildAssetDataSetting = CreateInstance<BuildAssetDataSetting>();
|
||||
@@ -174,6 +174,7 @@ namespace Stary.Evo.Editor
|
||||
AssetDatabase.LoadAssetAtPath<AssemblyDefinitionAsset>(configPath);
|
||||
if (domain != "Main")
|
||||
{
|
||||
|
||||
// 将程序集定义添加到 HybridCLR 热更列表
|
||||
var settings = SettingsUtil.HybridCLRSettings;
|
||||
if (!settings.hotUpdateAssemblyDefinitions.Contains(assemblyDefinitionAsset))
|
||||
@@ -195,8 +196,9 @@ namespace Stary.Evo.Editor
|
||||
|
||||
HybridCLRSettings.Instance.hotUpdateAssemblyDefinitions = assemblies.ToArray();
|
||||
HybridCLRSettings.Save();
|
||||
}
|
||||
|
||||
}
|
||||
#endif
|
||||
AssetDatabase.SaveAssets();
|
||||
|
||||
|
||||
@@ -215,7 +217,6 @@ namespace Stary.Evo.Editor
|
||||
}
|
||||
|
||||
|
||||
|
||||
[TitleGroup("预览Domain作用域")] public List<CreatDomainEntity> domainList;
|
||||
|
||||
protected override void Initialize()
|
||||
@@ -319,7 +320,7 @@ namespace Stary.Evo.Editor
|
||||
CreatDirectory(artDomainPath + "/Shader");
|
||||
//创建Textures文件夹
|
||||
CreatDirectory(artDomainPath + "/Textures");
|
||||
|
||||
|
||||
string domainPath = $"{Application.dataPath}/Domain/{domain}";
|
||||
//程序资源存放文件夹
|
||||
string resPath = $"{domainPath}/AddressableRes";
|
||||
@@ -340,7 +341,7 @@ namespace Stary.Evo.Editor
|
||||
CreatDirectory(resPath + "/Sprites");
|
||||
//创建Video文件夹
|
||||
CreatDirectory(resPath + "/Video");
|
||||
|
||||
|
||||
AssetDatabase.Refresh();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using Stary.Evo.Editor;
|
||||
using System;
|
||||
using Stary.Evo.Editor;
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
|
||||
@@ -9,19 +10,70 @@ namespace Stary.Evo
|
||||
{
|
||||
static CreatDomainDirectory()
|
||||
{
|
||||
if (PlayerPrefs.GetInt("CreatDomainDirectory") == 0)
|
||||
// 注意 因为这个构造函数会被重复调用,
|
||||
//所以为了防止quitting和update两个回调被重复添加,需要先移除后添加
|
||||
EditorApplication.quitting -= OnEditorQuit;
|
||||
EditorApplication.quitting += OnEditorQuit;
|
||||
|
||||
Debug.Log(" 自动运行 ");
|
||||
|
||||
if (!PlayerPrefs.HasKey("StartUp"))
|
||||
{
|
||||
PlayerPrefs.SetInt("CreatDomainDirectory", 1);
|
||||
bool isOk = EditorUtility.DisplayDialog("提示", "发现目录存在缺失,是否检索并创建缺失目录", "是", "否");
|
||||
if (isOk)
|
||||
// 通过标记记录是否已经执行过该方法
|
||||
OnEditorStartUp();
|
||||
PlayerPrefs.SetInt("StartUp", 1);
|
||||
|
||||
if (PlayerPrefs.GetInt("CreatDomainDirectory") == 0)
|
||||
{
|
||||
var DomainAll = CreatAssetWindow.GetCreatDomainAll();
|
||||
foreach (var domain in DomainAll)
|
||||
PlayerPrefs.SetInt("CreatDomainDirectory", 1);
|
||||
bool isOk = EditorUtility.DisplayDialog("提示", "发现目录存在缺失,是否检索并创建缺失目录", "是", "否");
|
||||
if (isOk)
|
||||
{
|
||||
CreatAssetWindow.CreateDomainDirectory(domain.DomainName);
|
||||
var DomainAll = CreatAssetWindow.GetCreatDomainAll();
|
||||
foreach (var domain in DomainAll)
|
||||
{
|
||||
CreatAssetWindow.CreateDomainDirectory(domain.DomainName);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (EditorPrefs.GetString("ChangeHotUpdateSchema") == "")
|
||||
{
|
||||
ChangeHotUpdateSchema.SetHotUpdateMode(HotUpdateMode.NotUpdate);
|
||||
}
|
||||
else
|
||||
{
|
||||
ChangeHotUpdateSchema.SetHotUpdateMode(
|
||||
Enum.Parse<HotUpdateMode>(EditorPrefs.GetString("ChangeHotUpdateSchema")));
|
||||
}
|
||||
|
||||
if (EditorPrefs.GetString("ChangePlayerSchema") == "")
|
||||
{
|
||||
ChangePlayerSchema.SetPlayerMode(PLayerMode.EDITOR_SIMULATEMODE);
|
||||
}
|
||||
else
|
||||
{
|
||||
ChangePlayerSchema.SetPlayerMode(
|
||||
Enum.Parse<PLayerMode>(EditorPrefs.GetString("ChangePlayerSchema")));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// UnityEditor 关闭时取消标记
|
||||
/// </summary>
|
||||
private static void OnEditorQuit()
|
||||
{
|
||||
PlayerPrefs.DeleteKey("StartUp");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 只会在UnityEditor启动时执行一次
|
||||
/// </summary>
|
||||
static void OnEditorStartUp()
|
||||
{
|
||||
Debug.Log(" UnityEditor 启动 ");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,7 +1,9 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading.Tasks;
|
||||
#if HotUpdate
|
||||
using HybridCLR.Editor.Commands;
|
||||
#endif
|
||||
using Newtonsoft.Json;
|
||||
using Sirenix.OdinInspector;
|
||||
using Sirenix.OdinInspector.Editor;
|
||||
@@ -16,8 +18,19 @@ namespace Stary.Evo.Editor
|
||||
[MenuItem("Evo/(一键)打包工具")]
|
||||
static void Init()
|
||||
{
|
||||
var window = (OneKeyBuildWindow)EditorWindow.GetWindow(typeof(OneKeyBuildWindow));
|
||||
#if NotUpdate
|
||||
if (EditorUtility.DisplayDialog("提示", "当前为非热更模式,不支持热更打包功能,是否切换热更模式", "是", "否"))
|
||||
{
|
||||
ChangeHotUpdateSchema.SetHotUpdateMode(HotUpdateMode.HotUpdate);
|
||||
}
|
||||
#elif HotUpdate
|
||||
var window = (OneKeyBuildWindow)EditorWindow.GetWindow(typeof(OneKeyBuildWindow));
|
||||
window.Show();
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
[Title("全选"), OnValueChanged("OneKeyBuildEvent"), HideLabel]
|
||||
@@ -44,6 +57,7 @@ namespace Stary.Evo.Editor
|
||||
[Button("(一键)标记选择资源", ButtonSizes.Large)]
|
||||
public void OneClickMark()
|
||||
{
|
||||
#if HotUpdate
|
||||
//打dll
|
||||
CompileDllCommand.CompileDllActiveBuildTarget();
|
||||
//拷贝dll
|
||||
@@ -51,6 +65,7 @@ namespace Stary.Evo.Editor
|
||||
//标记全部资源
|
||||
MarkAdressable.AddMarkAll(OneKeyBuildEntities);
|
||||
EditorUtility.DisplayDialog("提示", $"标记所有资源完成!", "确定");
|
||||
#endif
|
||||
}
|
||||
|
||||
[Button("(一键)获取服务器版本", ButtonSizes.Large)]
|
||||
|
||||
8
Assets/00.StaryEvo/Editor/Entity.meta
Normal file
8
Assets/00.StaryEvo/Editor/Entity.meta
Normal file
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 281c4d7ec043eaf4290db0498dd5294d
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,29 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using Stary.Evo;
|
||||
using Stary.Evo.Editor;
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
|
||||
[CustomEditor(typeof(HotfixMainResDomain))]
|
||||
public class HotfixMainResDomainEditor : UnityEditor.Editor
|
||||
{
|
||||
/// <summary>
|
||||
/// 序列化属性,在OnEnable中获取
|
||||
/// </summary>
|
||||
[HideInInspector]
|
||||
private SerializedProperty projectInfo;
|
||||
|
||||
private void OnEnable()
|
||||
{
|
||||
projectInfo = serializedObject.FindProperty("projectInfo");
|
||||
|
||||
}
|
||||
|
||||
public override void OnInspectorGUI()
|
||||
{
|
||||
base.OnInspectorGUI();
|
||||
HotfixMainResDomain hotfixMainResDomain = (HotfixMainResDomain)target;
|
||||
hotfixMainResDomain.projectInfo.projectPackageName = $"com.xosmo.{hotfixMainResDomain.projectInfo.projectCode}";
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: cb7e2ce39e1df99428ebf42ff0e04a19
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,8 +1,11 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
|
||||
#if HotUpdate
|
||||
using HybridCLR.Editor;
|
||||
using HybridCLR.Editor.Commands;
|
||||
#endif
|
||||
using UnityEditor;
|
||||
using UnityEditor.U2D;
|
||||
using UnityEngine;
|
||||
@@ -23,23 +26,6 @@ namespace Stary.Evo.Editor
|
||||
}
|
||||
|
||||
|
||||
// public static string SpriteRemotedAtlas
|
||||
// {
|
||||
// get { return Application.dataPath + "/AddressableRes/SpriteAtlas"; }
|
||||
// }
|
||||
|
||||
|
||||
//[MenuItem("Evo/Hotfix/BuildAll")]
|
||||
public static void BuildAll()
|
||||
{
|
||||
PrebuildCommand.GenerateAll();
|
||||
Debug.Log("UnityEvo:Build【GenerateAll】完成");
|
||||
AddHotfixAddressableDll();
|
||||
Debug.Log("UnityEvo:Build【CopyHotfixAddressableDll】完成");
|
||||
AddMark();
|
||||
Debug.Log("UnityEvo:Build【MarkAsset】完成");
|
||||
}
|
||||
|
||||
|
||||
//[MenuItem("Evo/Hotfix/Addressable")]
|
||||
public static void AddHotfixAddressableDll()
|
||||
@@ -72,6 +58,7 @@ namespace Stary.Evo.Editor
|
||||
|
||||
private static void CopyDllHotUpdateAssembly(string domain, string target)
|
||||
{
|
||||
#if HotUpdate
|
||||
//读取打包dll位置
|
||||
string hotUpdateDir =
|
||||
$"{SettingsUtil.HybridCLRSettings.hotUpdateDllCompileOutputRootDir}/{EditorUserBuildSettings.activeBuildTarget}";
|
||||
@@ -104,10 +91,12 @@ namespace Stary.Evo.Editor
|
||||
FileUtility.Copy(hotfixDllPathPdb, hotfixDllPathPdbTarget, true);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
private static void CopyDllStrippedAOTDllOutputRootDir(string target)
|
||||
{
|
||||
#if HotUpdate
|
||||
//读取打包dll位置
|
||||
string hotUpdateDir =
|
||||
$"{SettingsUtil.HybridCLRSettings.strippedAOTDllOutputRootDir}/{EditorUserBuildSettings.activeBuildTarget}";
|
||||
@@ -118,6 +107,7 @@ namespace Stary.Evo.Editor
|
||||
$"{target}/Dll/{EditorUserBuildSettings.activeBuildTarget}/{dll}.bytes";
|
||||
FileUtility.Copy(hotfixDllPath, hotfixDllPathTarget, true);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
public static void AddMarkAll(List<OneKeyBuildEntity> oneKeyBUildEntities)
|
||||
@@ -530,5 +520,6 @@ namespace Stary.Evo.Editor
|
||||
};
|
||||
ShaderVariantCollector.Run(localSavePath,BuildAssetWindow.GetBuildPackageName(),1000, completedCallback);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user