【m】优化HotfixMainResDomain配置文件
1.添加配置文件全局获取方法HotfixMainResDomain.Get,含不存在时补充创建逻辑 2.优化加载场景的缺失提示和获取途径,处理选中配置文件时循环报错的问题 3.添加包体配置项,允许对子包配置做独立处理
This commit is contained in:
@@ -1,4 +1,5 @@
|
|||||||
using System;
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
using Sirenix.OdinInspector;
|
using Sirenix.OdinInspector;
|
||||||
using UnityEditor;
|
using UnityEditor;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
@@ -8,8 +9,41 @@ namespace Stary.Evo
|
|||||||
[CreateAssetMenu(fileName = "HotfixMainResDomain", menuName = "Evo/Create HotfixMainResDomain")]
|
[CreateAssetMenu(fileName = "HotfixMainResDomain", menuName = "Evo/Create HotfixMainResDomain")]
|
||||||
public class HotfixMainResDomain : ScriptableObject
|
public class HotfixMainResDomain : ScriptableObject
|
||||||
{
|
{
|
||||||
|
[TabGroup("MainResDomain")]
|
||||||
|
[InlineProperty, HideLabel]
|
||||||
public HotfixMainResDomainEntity hotfixMainResDomainEntity;
|
public HotfixMainResDomainEntity hotfixMainResDomainEntity;
|
||||||
|
|
||||||
|
[TabGroup("ProjectInfo")]
|
||||||
|
[InlineProperty, HideLabel]
|
||||||
public ProjectInfo projectInfo;
|
public ProjectInfo projectInfo;
|
||||||
|
|
||||||
|
[TabGroup("BuildConfig")]
|
||||||
|
[InlineProperty, HideLabel]
|
||||||
|
public BuildConfig buildConfig;
|
||||||
|
|
||||||
|
private static HotfixMainResDomain globalInstance;
|
||||||
|
public static HotfixMainResDomain Get
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
// 在Resources目录下查找配置
|
||||||
|
if (globalInstance == null)
|
||||||
|
{
|
||||||
|
globalInstance = Resources.Load<HotfixMainResDomain>("HotfixMainResDomain");
|
||||||
|
}
|
||||||
|
// 无该配置时尝试创建
|
||||||
|
else if (globalInstance == null)
|
||||||
|
{
|
||||||
|
globalInstance = CreateInstance<HotfixMainResDomain>();
|
||||||
|
var path = AssetDatabase.GenerateUniqueAssetPath("Resources/HotfixMainResDomain.asset");
|
||||||
|
AssetDatabase.CreateAsset(globalInstance, path);
|
||||||
|
AssetDatabase.SaveAssets();
|
||||||
|
AssetDatabase.Refresh();
|
||||||
|
}
|
||||||
|
// 返回热更资源配置
|
||||||
|
return globalInstance;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
[Serializable]
|
[Serializable]
|
||||||
@@ -37,14 +71,61 @@ namespace Stary.Evo
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// 项目包名
|
/// 项目包名
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[ReadOnly] public string projectPackageName;
|
|
||||||
|
|
||||||
#if UNITY_EDITOR
|
|
||||||
|
|
||||||
public SceneAsset loadingScene;
|
|
||||||
#endif
|
|
||||||
[ReadOnly]
|
[ReadOnly]
|
||||||
public string loadingScenePath;
|
public string projectPackageName;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 资源加载场景
|
||||||
|
/// </summary>
|
||||||
|
[LabelText("资源加载场景")]
|
||||||
|
[Required("如果需要场景作为资源加载过程中的过渡,请将其拖到此处")]
|
||||||
|
public SceneAsset loadingScene;
|
||||||
|
/// <summary>
|
||||||
|
/// 资源加载场景(路径)
|
||||||
|
/// </summary>
|
||||||
|
public string loadingScenePath => AssetDatabase.GetAssetPath(loadingScene);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[Serializable]
|
||||||
|
public class BuildConfig
|
||||||
|
{
|
||||||
|
[LabelText("包体配置")]
|
||||||
|
private List<PackageConfig> packages = new();
|
||||||
|
|
||||||
|
public PackageConfig Get(string packageID)
|
||||||
|
{
|
||||||
|
var result = packages.Find(x=>x.packageID==packageID);
|
||||||
|
if (result == null)
|
||||||
|
{
|
||||||
|
result = new PackageConfig();
|
||||||
|
packages.Add(result);
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Set(string packageID, PackageConfigInfo config)
|
||||||
|
{
|
||||||
|
var package = Get(packageID);
|
||||||
|
package.info = config;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
[Serializable]
|
||||||
|
public class PackageConfig
|
||||||
|
{
|
||||||
|
[FoldoutGroup("@packageID")]
|
||||||
|
[LabelText("包体ID")]
|
||||||
|
public string packageID;
|
||||||
|
[FoldoutGroup("@packageID")]
|
||||||
|
[InlineProperty, HideLabel]
|
||||||
|
public PackageConfigInfo info;
|
||||||
|
}
|
||||||
|
|
||||||
|
[Serializable]
|
||||||
|
public class PackageConfigInfo
|
||||||
|
{
|
||||||
|
[LabelText("App名称")]
|
||||||
|
public string appName;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "com.staryevo.main",
|
"name": "com.staryevo.main",
|
||||||
"version": "2.1.0",
|
"version": "2.1.1",
|
||||||
"displayName": "00.StaryEvo",
|
"displayName": "00.StaryEvo",
|
||||||
"description": "This is an Framework package(后台服务器版本,端口9527)",
|
"description": "This is an Framework package(后台服务器版本,端口9527)",
|
||||||
"unity": "2021.3",
|
"unity": "2021.3",
|
||||||
|
|||||||
Reference in New Issue
Block a user