Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

增加收集配置可输入的收集路径,以支持非工程文件路径 #247

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using UnityEditor;
using UnityEngine;
Expand Down Expand Up @@ -149,7 +150,9 @@ public List<CollectAssetInfo> GetAllCollectAssets(CollectCommand command, AssetB
Dictionary<string, CollectAssetInfo> result = new Dictionary<string, CollectAssetInfo>(1000);

// 收集打包资源路径
List<string> findAssets =new List<string>();
List<string> findAssets = new List<string>();

//收集路径是工程文件夹
if (AssetDatabase.IsValidFolder(CollectPath))
{
string collectDirectory = CollectPath;
Expand All @@ -159,7 +162,31 @@ public List<CollectAssetInfo> GetAllCollectAssets(CollectCommand command, AssetB
else
{
string assetPath = CollectPath;
findAssets.Add(assetPath);

var extra = AssetDatabase.LoadAssetAtPath<ExtraCollectPath>(assetPath);

if (extra != null)
{
if (!string.IsNullOrEmpty(extra.path))
{
if(Directory.Exists(extra.path))
{
string[] files = Directory.GetFiles(extra.path, "*", SearchOption.AllDirectories);
foreach (var file in files)
{
findAssets.Add(EditorTools.GetRegularPath(file));
}
}
else if (File.Exists(extra.path))
{
findAssets.Add(extra.path);
}
}
}
else
{
findAssets.Add(assetPath);
}
}

// 收集打包资源信息
Expand Down
12 changes: 12 additions & 0 deletions Assets/YooAsset/Editor/AssetBundleCollector/ExtraCollectPath.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

namespace YooAsset.Editor
{
[CreateAssetMenu(fileName = "ExtraCollectPath", menuName = "YooAsset/Create ExtraCollectPath")]
public class ExtraCollectPath : ScriptableObject
{
public string path;
}
}

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,14 @@ internal override void InternalOnUpdate()
if (_steps == ESteps.None)
{
// 检测资源文件是否存在
string guid = UnityEditor.AssetDatabase.AssetPathToGUID(MainAssetInfo.AssetPath);
if (string.IsNullOrEmpty(guid))
{
string error = $"Not found asset : {MainAssetInfo.AssetPath}";
YooLogger.Error(error);
InvokeCompletion(error, EOperationStatus.Failed);
return;
}
//string guid = UnityEditor.AssetDatabase.AssetPathToGUID(MainAssetInfo.AssetPath);
//if (string.IsNullOrEmpty(guid))
//{
// string error = $"Not found asset : {MainAssetInfo.AssetPath}";
// YooLogger.Error(error);
// InvokeCompletion(error, EOperationStatus.Failed);
// return;
//}

_steps = ESteps.CheckBundle;

Expand Down