Update YooAsset

Update YooAsset
This commit is contained in:
Alex-Rachel
2025-05-10 20:58:24 +08:00
parent 35a9729930
commit cc799ce426
10 changed files with 120 additions and 22 deletions

View File

@@ -1,5 +1,6 @@
using System.Collections.Generic;
#if YOO_ASSET_EXPERIMENT
namespace YooAsset.Editor
{
public class MacroDefine
@@ -15,3 +16,4 @@ namespace YooAsset.Editor
};
}
}
#endif

View File

@@ -5,6 +5,7 @@ using System.Text;
using System.Xml;
using UnityEditor;
#if YOO_ASSET_EXPERIMENT
namespace YooAsset.Editor
{
[InitializeOnLoad]
@@ -22,13 +23,21 @@ namespace YooAsset.Editor
return content;
// 将修改后的XML结构重新输出为文本
var stringWriter = new StringWriter();
var writerSettings = new XmlWriterSettings();
writerSettings.Indent = true;
var xmlWriter = XmlWriter.Create(stringWriter, writerSettings);
xmlDoc.WriteTo(xmlWriter);
xmlWriter.Flush();
return stringWriter.ToString();
using (var memoryStream = new MemoryStream())
{
var writerSettings = new XmlWriterSettings
{
Indent = true,
Encoding = new UTF8Encoding(false), //无BOM
OmitXmlDeclaration = false
};
using (var xmlWriter = XmlWriter.Create(memoryStream, writerSettings))
{
xmlDoc.Save(xmlWriter);
}
return Encoding.UTF8.GetString(memoryStream.ToArray());
}
}
/// <summary>
@@ -94,3 +103,4 @@ namespace YooAsset.Editor
}
}
}
#endif