mirror of
https://github.com/Alex-Rachel/TEngine.git
synced 2025-08-07 16:45:10 +00:00
add:初始化指定资源包
This commit is contained in:
@@ -86,8 +86,9 @@ namespace TEngine
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// 初始化操作。
|
/// 初始化操作。
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
/// <param name="packageName">指定资源包的名称。不传使用默认资源包</param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
InitializationOperation InitPackage();
|
InitializationOperation InitPackage(string packageName = "");
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 卸载资源。
|
/// 卸载资源。
|
||||||
|
@@ -15,7 +15,7 @@ namespace TEngine
|
|||||||
#region Propreties
|
#region Propreties
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 资源包名称。
|
/// 默认资源包名称。
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public string PackageName { get; set; } = "DefaultPackage";
|
public string PackageName { get; set; } = "DefaultPackage";
|
||||||
|
|
||||||
@@ -332,18 +332,24 @@ namespace TEngine
|
|||||||
/// 初始化资源包裹。
|
/// 初始化资源包裹。
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <returns>初始化资源包裹操作句柄。</returns>
|
/// <returns>初始化资源包裹操作句柄。</returns>
|
||||||
public InitializationOperation InitPackage()
|
public InitializationOperation InitPackage(string packageName = "")
|
||||||
{
|
{
|
||||||
// 创建默认的资源包
|
// 创建默认的资源包
|
||||||
string packageName = PackageName;
|
var targetPackageName = string.IsNullOrEmpty(packageName) || packageName.Equals(PackageName)
|
||||||
var package = YooAssets.TryGetPackage(packageName);
|
? PackageName
|
||||||
|
: packageName;
|
||||||
|
var package = YooAssets.TryGetPackage(targetPackageName);
|
||||||
if (package == null)
|
if (package == null)
|
||||||
{
|
{
|
||||||
package = YooAssets.CreatePackage(packageName);
|
package = YooAssets.CreatePackage(targetPackageName);
|
||||||
YooAssets.SetDefaultPackage(package);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
DefaultPackage = package;
|
// 设置默认资源包
|
||||||
|
if (targetPackageName.Equals(PackageName))
|
||||||
|
{
|
||||||
|
YooAssets.SetDefaultPackage(package);
|
||||||
|
DefaultPackage = package;
|
||||||
|
}
|
||||||
|
|
||||||
#if UNITY_EDITOR
|
#if UNITY_EDITOR
|
||||||
//编辑器模式使用。
|
//编辑器模式使用。
|
||||||
@@ -359,7 +365,7 @@ namespace TEngine
|
|||||||
if (playMode == EPlayMode.EditorSimulateMode)
|
if (playMode == EPlayMode.EditorSimulateMode)
|
||||||
{
|
{
|
||||||
var createParameters = new EditorSimulateModeParameters();
|
var createParameters = new EditorSimulateModeParameters();
|
||||||
createParameters.SimulateManifestFilePath = EditorSimulateModeHelper.SimulateBuild(packageName);
|
createParameters.SimulateManifestFilePath = EditorSimulateModeHelper.SimulateBuild(targetPackageName);
|
||||||
initializationOperation = package.InitializeAsync(createParameters);
|
initializationOperation = package.InitializeAsync(createParameters);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user