Compare commits

...

8 Commits

Author SHA1 Message Date
Y-way
8d746ca519 Merge bdcf95384f into b334a4986b 2025-03-12 13:41:36 +08:00
何冠峰
b334a4986b fix #504 2025-03-12 10:39:44 +08:00
何冠峰
a4111349a0 fix #502 2025-03-11 15:40:57 +08:00
Y-way
bdcf95384f Update .gitignore 2025-03-10 16:13:18 +08:00
Y-way
d910af589d Update MacrosProcessor.cs
修正YooAsset相关宏在引用库不能生效的问题.
2025-03-10 15:22:44 +08:00
何冠峰
0531864534 Update package.json 2025-03-10 10:29:44 +08:00
何冠峰
72b1278f5c Merge pull request #499 from benjamini258369gmail/fix-rawIgnore-dll
fix ignore raw dll
2025-03-10 10:27:13 +08:00
benjamini
875cd24cba fix ignore raw dll 2025-03-08 17:54:11 +09:00
5 changed files with 126 additions and 10 deletions

4
.gitignore vendored
View File

@@ -72,4 +72,6 @@ sysinfo.txt
# Crashlytics generated file
crashlytics-build.properties
*.vsconfig
*.vsconfig
Assets/csc.rsp
Assets/csc.rsp.meta

View File

@@ -1,18 +1,20 @@
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Xml;
using UnityEditor;
using UnityEditor.PackageManager;
using UnityEngine;
using static UnityEditor.PlayerSettings;
namespace YooAsset.Editor
{
[InitializeOnLoad]
public class MacrosProcessor : AssetPostprocessor
{
static MacrosProcessor()
{
}
// csc.rsp 文件路径
private static string RspFilePath => Path.Combine(Application.dataPath, "csc.rsp");
/// <summary>
/// YooAsset版本宏定义
/// </summary>
@@ -23,6 +25,12 @@ namespace YooAsset.Editor
"YOO_ASSET_2_3_OR_NEWER",
};
static MacrosProcessor()
{
//添加到全局宏定义
UpdateRspFile(YooAssetMacros);
}
static string OnGeneratedCSProject(string path, string content)
{
XmlDocument xmlDoc = new XmlDocument();
@@ -105,5 +113,102 @@ namespace YooAsset.Editor
return false;
}
/// <summary>
/// 更新csc.rsp文件
/// </summary>
/// <param name="macrosToAdd"></param>
/// <param name="macrosToRemove"></param>
private static void UpdateRspFile(List<string> macrosToAdd = null, List<string> macrosToRemove = null)
{
HashSet<string> existingDefines = new HashSet<string>();
List<string> otherLines = new List<string>();
// 1. 读取现有内容
ReadRspFile(ref existingDefines, ref otherLines);
// 2. 添加新宏
if (macrosToAdd != null && macrosToAdd.Count > 0)
{
macrosToAdd.ForEach(x =>
{
if (existingDefines.Contains(x) == false)
existingDefines.Add(x);
});
}
// 3. 移除指定宏
if (macrosToRemove != null && macrosToRemove.Count > 0)
{
macrosToRemove.ForEach(x =>
{
existingDefines.Remove(x);
});
}
// 4. 重新生成内容
WriteRspFile(existingDefines, otherLines);
// 5. 刷新AssetDatabase
AssetDatabase.Refresh();
EditorUtility.RequestScriptReload();
}
/// <summary>
/// 读取csc.rsp文件,返回宏定义和其他行
/// </summary>
/// <param name="defines"></param>
/// <param name="others"></param>
private static void ReadRspFile(ref HashSet<string> defines, ref List<string> others)
{
if (defines == null)
{
defines = new HashSet<string>();
}
if (others == null)
{
others = new List<string>();
}
if (File.Exists(RspFilePath) == false)
{
return;
}
foreach (string line in File.ReadAllLines(RspFilePath))
{
if (line.StartsWith("-define:"))
{
string[] parts = line.Split(new[] { ':' }, 2);
if (parts.Length == 2)
{
defines.Add(parts[1].Trim());
}
}
else
{
others.Add(line);
}
}
}
/// <summary>
/// 重写入出csc.rsp文件
/// </summary>
/// <param name="defines"></param>
/// <param name="others"></param>
private static void WriteRspFile(HashSet<string> defines, List<string> others)
{
StringBuilder sb = new StringBuilder();
if (others != null && others.Count > 0)
{
others.ForEach(o => sb.AppendLine(o));
}
if (defines != null && defines.Count > 0)
{
foreach (string define in defines)
{
sb.AppendLine($"-define:{define}");
}
}
File.WriteAllText(RspFilePath, sb.ToString());
}
}
}

View File

@@ -10,7 +10,7 @@ namespace YooAsset.Editor
/// <summary>
/// 忽略的文件类型
/// </summary>
public readonly static HashSet<string> IgnoreFileExtensions = new HashSet<string>() { "", ".so", ".dll", ".cs", ".js", ".boo", ".meta", ".cginc", ".hlsl" };
public readonly static HashSet<string> IgnoreFileExtensions = new HashSet<string>() { "", ".so", ".cs", ".js", ".boo", ".meta", ".cginc", ".hlsl" };
}
/// <summary>

View File

@@ -37,7 +37,9 @@ namespace YooAsset
string url;
// 获取对应平台的URL地址
#if UNITY_EDITOR
#if UNITY_EDITOR_OSX
url = StringUtility.Format("file://{0}", path);
#elif UNITY_EDITOR
url = StringUtility.Format("file:///{0}", path);
#elif UNITY_WEBGL
url = path;

View File

@@ -85,15 +85,22 @@ namespace YooAsset
// 创建验证元素类
string fileRootPath = chidDirectory.FullName;
string dataFilePath = $"{fileRootPath}/{ DefaultCacheFileSystemDefine.BundleDataFileName}";
string infoFilePath = $"{fileRootPath}/{ DefaultCacheFileSystemDefine.BundleInfoFileName}";
string dataFilePath = $"{fileRootPath}/{DefaultCacheFileSystemDefine.BundleDataFileName}";
string infoFilePath = $"{fileRootPath}/{DefaultCacheFileSystemDefine.BundleInfoFileName}";
// 存储的数据文件追加文件格式
if (_fileSystem.AppendFileExtension)
{
string dataFileExtension = FindDataFileExtension(chidDirectory);
if (string.IsNullOrEmpty(dataFileExtension) == false)
if (string.IsNullOrEmpty(dataFileExtension))
{
//注意:覆盖安装的情况下,缓存文件可能会没有后缀格式,需要删除重新下载!
dataFilePath = string.Empty;
}
else
{
dataFilePath += dataFileExtension;
}
}
var element = new VerifyFileElement(_fileSystem.PackageName, bundleGUID, fileRootPath, dataFilePath, infoFilePath);