Update AssetBundleBuilder

pull/24/head
hevinci 2022-07-13 11:59:15 +08:00
parent ea9b8874cc
commit e68ece6925
2 changed files with 26 additions and 0 deletions

View File

@ -26,6 +26,17 @@ namespace YooAsset.Editor
if (string.IsNullOrEmpty(buildParameters.PipelineOutputDirectory)) if (string.IsNullOrEmpty(buildParameters.PipelineOutputDirectory))
throw new Exception("输出目录不能为空"); throw new Exception("输出目录不能为空");
// 检测当前是否正在构建资源包
if (BuildPipeline.isBuildingPlayer)
throw new Exception("当前正在构建资源包,请结束后再试");
// 检测是否有未保存场景
if (EditorTools.HasDirtyScenes())
throw new Exception("检测到未保存的场景文件");
// 保存改动的资源
AssetDatabase.SaveAssets();
// 增量更新时候的必要检测 // 增量更新时候的必要检测
var buildMode = buildParameters.Parameters.BuildMode; var buildMode = buildParameters.Parameters.BuildMode;
if (buildMode == EBuildMode.IncrementalBuild) if (buildMode == EBuildMode.IncrementalBuild)

View File

@ -7,6 +7,7 @@ using System.IO;
using System.Text; using System.Text;
using UnityEngine; using UnityEngine;
using UnityEditor; using UnityEditor;
using UnityEditor.SceneManagement;
namespace YooAsset.Editor namespace YooAsset.Editor
{ {
@ -265,6 +266,20 @@ namespace YooAsset.Editor
} }
#endregion #endregion
#region SceneUtility
public static bool HasDirtyScenes()
{
var sceneCount = EditorSceneManager.sceneCount;
for (var i = 0; i < sceneCount; ++i)
{
var scene = EditorSceneManager.GetSceneAt(i);
if (scene.isDirty)
return true;
}
return false;
}
#endregion
#region 文件 #region 文件
/// <summary> /// <summary>
/// 创建文件所在的目录 /// 创建文件所在的目录