【m】build apk 开发
This commit is contained in:
@@ -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,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 7dfc7b6280e2426a81a5ead99db006f7
|
||||
timeCreated: 1741232911
|
||||
@@ -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
|
||||
@@ -0,0 +1,90 @@
|
||||
using System;
|
||||
using System.Linq;
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Stary.Evo.Editor
|
||||
{
|
||||
public class ChangePlayerSchema
|
||||
{
|
||||
public static PLayerMode PLayerMode
|
||||
{
|
||||
get => _pLayerMode;
|
||||
set => SetPlayerMode(value);
|
||||
}
|
||||
|
||||
private static PLayerMode _pLayerMode;
|
||||
|
||||
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);
|
||||
|
||||
[MenuItem(OfflinePlayMode)]
|
||||
private static void SetOfflineMode() => SetPlayerMode(PLayerMode.OFFLINE_PLAYMODE);
|
||||
|
||||
[MenuItem(HostPlayMode)]
|
||||
private static void SetHostMode() => SetPlayerMode(PLayerMode.HOST_PLAYMODE);
|
||||
|
||||
// [MenuItem(WebPlayMode)]
|
||||
// private static void SetWebMode() => SetPlayerMode(PLayerMode.WEB_PLAYMODE);
|
||||
|
||||
[MenuItem(EditorSimulateMode, true)]
|
||||
private static bool ValidateModeMenu()
|
||||
{
|
||||
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());
|
||||
Debug.LogError("CheckPlatform");
|
||||
return true;
|
||||
}
|
||||
|
||||
public static void SetPlayerMode(PLayerMode mode)
|
||||
{
|
||||
// 清除所有旧模式定义
|
||||
var currentTarget = EditorUserBuildSettings.selectedBuildTargetGroup;
|
||||
if (currentTarget == BuildTargetGroup.Unknown) return;
|
||||
|
||||
var defines = PlayerSettings.GetScriptingDefineSymbolsForGroup(currentTarget)
|
||||
.Split(';')
|
||||
.Where(d => !Enum.GetNames(typeof(PLayerMode)).Contains(d))
|
||||
.ToList();
|
||||
|
||||
// 添加新模式
|
||||
defines.Add(mode.ToString());
|
||||
PlayerSettings.SetScriptingDefineSymbolsForGroup(currentTarget, string.Join(";", defines));
|
||||
Debug.Log($"当前编译符号: {string.Join(";", defines)}"); // 添加调试日志
|
||||
_pLayerMode = mode;
|
||||
EditorPrefs.SetString("ChangePlayerSchema", _pLayerMode.ToString());
|
||||
ValidateModeMenu();
|
||||
AssetDatabase.Refresh();
|
||||
// 添加解决方案文件重新生成逻辑
|
||||
EditorApplication.delayCall += () =>
|
||||
{
|
||||
EditorApplication.ExecuteMenuItem("Assets/Open C# Project");
|
||||
UnityEditor.Compilation.CompilationPipeline.RequestScriptCompilation();
|
||||
Debug.Log("已强制重新生成解决方案文件");
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
public enum PLayerMode
|
||||
{
|
||||
//编辑仿真模式,
|
||||
EDITOR_SIMULATEMODE,
|
||||
|
||||
//单机运行模式
|
||||
OFFLINE_PLAYMODE,
|
||||
|
||||
//联机运行模式
|
||||
HOST_PLAYMODE,
|
||||
|
||||
// //web运行模式
|
||||
// WEB_PLAYMODE
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 28520dd6a62c460d93fe8bb524b6a159
|
||||
timeCreated: 1741232924
|
||||
@@ -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)]
|
||||
|
||||
Reference in New Issue
Block a user