mirror of https://github.com/tuyoogame/YooAsset
Compare commits
No commits in common. "79467bbf13750b6dc748e0f38f55896d7e256acf" and "b334a4986bcf2b8a7bf95ed5f4bd6d4cc39eeb8f" have entirely different histories.
79467bbf13
...
b334a4986b
|
@ -20,8 +20,6 @@
|
|||
/Assets/StreamingAssets.meta
|
||||
/Assets/Samples
|
||||
/Assets/Samples.meta
|
||||
/Assets/csc.rsp
|
||||
/Assets/csc.rsp.meta
|
||||
/UserSettings
|
||||
|
||||
|
||||
|
|
|
@ -1,17 +0,0 @@
|
|||
using System.Collections.Generic;
|
||||
|
||||
namespace YooAsset.Editor
|
||||
{
|
||||
public class MacroDefine
|
||||
{
|
||||
/// <summary>
|
||||
/// YooAsset版本宏定义
|
||||
/// </summary>
|
||||
public static readonly List<string> Macros = new List<string>()
|
||||
{
|
||||
"YOO_ASSET_2",
|
||||
"YOO_ASSET_2_3",
|
||||
"YOO_ASSET_2_3_OR_NEWER",
|
||||
};
|
||||
}
|
||||
}
|
|
@ -1,11 +0,0 @@
|
|||
fileFormatVersion: 2
|
||||
guid: a61e5c2ca04aab647b1ed0492086aa8f
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -1,15 +1,28 @@
|
|||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Xml;
|
||||
using UnityEditor;
|
||||
|
||||
namespace YooAsset.Editor
|
||||
{
|
||||
[InitializeOnLoad]
|
||||
public class MacroProcessor : AssetPostprocessor
|
||||
public class MacrosProcessor : AssetPostprocessor
|
||||
{
|
||||
static MacrosProcessor()
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// YooAsset版本宏定义
|
||||
/// </summary>
|
||||
private static readonly List<string> YooAssetMacros = new List<string>()
|
||||
{
|
||||
"YOO_ASSET_2",
|
||||
"YOO_ASSET_2_3",
|
||||
"YOO_ASSET_2_3_OR_NEWER",
|
||||
};
|
||||
|
||||
static string OnGeneratedCSProject(string path, string content)
|
||||
{
|
||||
XmlDocument xmlDoc = new XmlDocument();
|
||||
|
@ -52,7 +65,7 @@ namespace YooAsset.Editor
|
|||
|
||||
string[] defines = childNode.InnerText.Split(';');
|
||||
HashSet<string> hashSets = new HashSet<string>(defines);
|
||||
foreach (string yooMacro in MacroDefine.Macros)
|
||||
foreach (string yooMacro in YooAssetMacros)
|
||||
{
|
||||
string tmpMacro = yooMacro.Trim();
|
||||
if (hashSets.Contains(tmpMacro) == false)
|
|
@ -1,115 +0,0 @@
|
|||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Xml;
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
|
||||
#if YOO_ASSET_EXPERIMENT
|
||||
namespace YooAsset.Editor.Experiment
|
||||
{
|
||||
[InitializeOnLoad]
|
||||
public class RspGenerator
|
||||
{
|
||||
// csc.rsp文件路径
|
||||
private static string RspFilePath => Path.Combine(Application.dataPath, "csc.rsp");
|
||||
|
||||
static RspGenerator()
|
||||
{
|
||||
UpdateRspFile(MacroDefine.Macros, null);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 更新csc.rsp文件
|
||||
/// </summary>
|
||||
private static void UpdateRspFile(List<string> addMacros, List<string> removeMacros)
|
||||
{
|
||||
var existingDefines = new HashSet<string>();
|
||||
var otherLines = new List<string>();
|
||||
|
||||
// 1. 读取现有内容
|
||||
ReadRspFile(existingDefines, otherLines);
|
||||
|
||||
// 2. 添加新宏
|
||||
if (addMacros != null && addMacros.Count > 0)
|
||||
{
|
||||
addMacros.ForEach(x =>
|
||||
{
|
||||
if (existingDefines.Contains(x) == false)
|
||||
existingDefines.Add(x);
|
||||
});
|
||||
}
|
||||
|
||||
// 3. 移除指定宏
|
||||
if (removeMacros != null && removeMacros.Count > 0)
|
||||
{
|
||||
removeMacros.ForEach(x =>
|
||||
{
|
||||
existingDefines.Remove(x);
|
||||
});
|
||||
}
|
||||
|
||||
// 4. 重新生成内容
|
||||
WriteRspFile(existingDefines, otherLines);
|
||||
|
||||
// 5. 刷新AssetDatabase
|
||||
AssetDatabase.Refresh();
|
||||
EditorUtility.RequestScriptReload();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 读取csc.rsp文件,返回宏定义和其他行
|
||||
/// </summary>
|
||||
private static void ReadRspFile(HashSet<string> defines, 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>
|
||||
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());
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
|
@ -1,11 +0,0 @@
|
|||
fileFormatVersion: 2
|
||||
guid: c2662e1d33b1eea469695b68d18b1739
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -3,16 +3,6 @@ namespace YooAsset
|
|||
{
|
||||
public class AssetInfo
|
||||
{
|
||||
internal enum ELoadMethod
|
||||
{
|
||||
None = 0,
|
||||
LoadAsset,
|
||||
LoadSubAssets,
|
||||
LoadAllAssets,
|
||||
LoadScene,
|
||||
LoadRawFile,
|
||||
}
|
||||
|
||||
private readonly PackageAsset _packageAsset;
|
||||
private string _providerGUID;
|
||||
|
||||
|
@ -31,11 +21,6 @@ namespace YooAsset
|
|||
/// </summary>
|
||||
public string Error { private set; get; }
|
||||
|
||||
/// <summary>
|
||||
/// 加载方法
|
||||
/// </summary>
|
||||
internal ELoadMethod LoadMethod;
|
||||
|
||||
/// <summary>
|
||||
/// 资源对象
|
||||
/// </summary>
|
||||
|
|
|
@ -174,7 +174,7 @@ namespace YooAsset
|
|||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取依赖列表
|
||||
/// 获取资源依赖列表
|
||||
/// 注意:传入的资源对象一定合法有效!
|
||||
/// </summary>
|
||||
public PackageBundle[] GetAllDependencies(PackageAsset packageAsset)
|
||||
|
@ -188,21 +188,6 @@ namespace YooAsset
|
|||
return result.ToArray();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取依赖列表
|
||||
/// 注意:传入的资源包对象一定合法有效!
|
||||
/// </summary>
|
||||
public PackageBundle[] GetAllDependencies(PackageBundle packageBundle)
|
||||
{
|
||||
List<PackageBundle> result = new List<PackageBundle>(packageBundle.DependBundleIDs.Length);
|
||||
foreach (var dependID in packageBundle.DependBundleIDs)
|
||||
{
|
||||
var dependBundle = GetMainPackageBundle(dependID);
|
||||
result.Add(dependBundle);
|
||||
}
|
||||
return result.ToArray();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 尝试获取包裹的资源
|
||||
/// </summary>
|
||||
|
|
|
@ -176,17 +176,7 @@ namespace YooAsset
|
|||
throw new Exception("Should never get here !");
|
||||
|
||||
// 注意:如果清单里未找到资源包会抛出异常!
|
||||
PackageBundle[] depends;
|
||||
if (assetInfo.LoadMethod == AssetInfo.ELoadMethod.LoadAllAssets)
|
||||
{
|
||||
var mainBundle = ActiveManifest.GetMainPackageBundle(assetInfo.Asset);
|
||||
depends = ActiveManifest.GetAllDependencies(mainBundle);
|
||||
}
|
||||
else
|
||||
{
|
||||
depends = ActiveManifest.GetAllDependencies(assetInfo.Asset);
|
||||
}
|
||||
|
||||
var depends = ActiveManifest.GetAllDependencies(assetInfo.Asset);
|
||||
List<BundleInfo> result = new List<BundleInfo>(depends.Length);
|
||||
foreach (var packageBundle in depends)
|
||||
{
|
||||
|
|
|
@ -610,7 +610,6 @@ namespace YooAsset
|
|||
private SceneHandle LoadSceneInternal(AssetInfo assetInfo, bool waitForAsyncComplete, LoadSceneMode sceneMode, LocalPhysicsMode physicsMode, bool suspendLoad, uint priority)
|
||||
{
|
||||
DebugCheckAssetLoadType(assetInfo.AssetType);
|
||||
assetInfo.LoadMethod = AssetInfo.ELoadMethod.LoadScene;
|
||||
var loadSceneParams = new LoadSceneParameters(sceneMode, physicsMode);
|
||||
var handle = _resourceManager.LoadSceneAsync(assetInfo, loadSceneParams, suspendLoad, priority);
|
||||
if (waitForAsyncComplete)
|
||||
|
@ -721,7 +720,6 @@ namespace YooAsset
|
|||
private AssetHandle LoadAssetInternal(AssetInfo assetInfo, bool waitForAsyncComplete, uint priority)
|
||||
{
|
||||
DebugCheckAssetLoadType(assetInfo.AssetType);
|
||||
assetInfo.LoadMethod = AssetInfo.ELoadMethod.LoadAsset;
|
||||
var handle = _resourceManager.LoadAssetAsync(assetInfo, priority);
|
||||
if (waitForAsyncComplete)
|
||||
handle.WaitForAsyncComplete();
|
||||
|
@ -831,7 +829,6 @@ namespace YooAsset
|
|||
private SubAssetsHandle LoadSubAssetsInternal(AssetInfo assetInfo, bool waitForAsyncComplete, uint priority)
|
||||
{
|
||||
DebugCheckAssetLoadType(assetInfo.AssetType);
|
||||
assetInfo.LoadMethod = AssetInfo.ELoadMethod.LoadSubAssets;
|
||||
var handle = _resourceManager.LoadSubAssetsAsync(assetInfo, priority);
|
||||
if (waitForAsyncComplete)
|
||||
handle.WaitForAsyncComplete();
|
||||
|
@ -941,7 +938,6 @@ namespace YooAsset
|
|||
private AllAssetsHandle LoadAllAssetsInternal(AssetInfo assetInfo, bool waitForAsyncComplete, uint priority)
|
||||
{
|
||||
DebugCheckAssetLoadType(assetInfo.AssetType);
|
||||
assetInfo.LoadMethod = AssetInfo.ELoadMethod.LoadAllAssets;
|
||||
var handle = _resourceManager.LoadAllAssetsAsync(assetInfo, priority);
|
||||
if (waitForAsyncComplete)
|
||||
handle.WaitForAsyncComplete();
|
||||
|
|
|
@ -23,10 +23,7 @@ namespace YooAsset
|
|||
{
|
||||
if (_assetBundle != null)
|
||||
{
|
||||
if (_packageBundle.Encrypted)
|
||||
_assetBundle.Unload(true);
|
||||
else
|
||||
_assetBundle.TTUnload(true);
|
||||
_assetBundle.TTUnload(true);
|
||||
}
|
||||
}
|
||||
public override string GetBundleFilePath()
|
||||
|
|
|
@ -11,7 +11,7 @@ namespace YooAsset
|
|||
private readonly IFileSystem _fileSystem;
|
||||
private readonly PackageBundle _packageBundle;
|
||||
private readonly AssetBundle _assetBundle;
|
||||
|
||||
|
||||
public WXAssetBundleResult(IFileSystem fileSystem, PackageBundle packageBundle, AssetBundle assetBundle)
|
||||
{
|
||||
_fileSystem = fileSystem;
|
||||
|
@ -23,10 +23,7 @@ namespace YooAsset
|
|||
{
|
||||
if (_assetBundle != null)
|
||||
{
|
||||
if (_packageBundle.Encrypted)
|
||||
_assetBundle.Unload(true);
|
||||
else
|
||||
_assetBundle.WXUnload(true);
|
||||
_assetBundle.WXUnload(true);
|
||||
}
|
||||
}
|
||||
public override string GetBundleFilePath()
|
||||
|
|
Loading…
Reference in New Issue