init
This commit is contained in:
+114
@@ -0,0 +1,114 @@
|
||||
//------------------------------------------------------------
|
||||
// Game Framework
|
||||
// Copyright © 2013-2021 Jiang Yin. All rights reserved.
|
||||
// Homepage: https://gameframework.cn/
|
||||
// Feedback: mailto:ellan@gameframework.cn
|
||||
//------------------------------------------------------------
|
||||
|
||||
using GameFramework.Resource;
|
||||
using System.IO;
|
||||
using System.Text;
|
||||
|
||||
namespace UnityGameFramework.Runtime
|
||||
{
|
||||
/// <summary>
|
||||
/// 内置版本资源列表序列化器。
|
||||
/// </summary>
|
||||
public static partial class BuiltinVersionListSerializer
|
||||
{
|
||||
/// <summary>
|
||||
/// 反序列化本地版本资源列表(版本 0)回调函数。
|
||||
/// </summary>
|
||||
/// <param name="stream">指定流。</param>
|
||||
/// <returns>反序列化的本地版本资源列表(版本 0)。</returns>
|
||||
public static LocalVersionList LocalVersionListDeserializeCallback_V0(Stream stream)
|
||||
{
|
||||
using (BinaryReader binaryReader = new BinaryReader(stream, Encoding.UTF8))
|
||||
{
|
||||
byte[] encryptBytes = binaryReader.ReadBytes(CachedHashBytesLength);
|
||||
int resourceCount = binaryReader.ReadInt32();
|
||||
LocalVersionList.Resource[] resources = resourceCount > 0 ? new LocalVersionList.Resource[resourceCount] : null;
|
||||
for (int i = 0; i < resourceCount; i++)
|
||||
{
|
||||
string name = binaryReader.ReadEncryptedString(encryptBytes);
|
||||
string variant = binaryReader.ReadEncryptedString(encryptBytes);
|
||||
byte loadType = binaryReader.ReadByte();
|
||||
int length = binaryReader.ReadInt32();
|
||||
int hashCode = binaryReader.ReadInt32();
|
||||
resources[i] = new LocalVersionList.Resource(name, variant, null, loadType, length, hashCode);
|
||||
}
|
||||
|
||||
return new LocalVersionList(resources, null);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 反序列化本地版本资源列表(版本 1)回调函数。
|
||||
/// </summary>
|
||||
/// <param name="stream">指定流。</param>
|
||||
/// <returns>反序列化的本地版本资源列表(版本 1)。</returns>
|
||||
public static LocalVersionList LocalVersionListDeserializeCallback_V1(Stream stream)
|
||||
{
|
||||
using (BinaryReader binaryReader = new BinaryReader(stream, Encoding.UTF8))
|
||||
{
|
||||
byte[] encryptBytes = binaryReader.ReadBytes(CachedHashBytesLength);
|
||||
int resourceCount = binaryReader.Read7BitEncodedInt32();
|
||||
LocalVersionList.Resource[] resources = resourceCount > 0 ? new LocalVersionList.Resource[resourceCount] : null;
|
||||
for (int i = 0; i < resourceCount; i++)
|
||||
{
|
||||
string name = binaryReader.ReadEncryptedString(encryptBytes);
|
||||
string variant = binaryReader.ReadEncryptedString(encryptBytes);
|
||||
string extension = binaryReader.ReadEncryptedString(encryptBytes) ?? DefaultExtension;
|
||||
byte loadType = binaryReader.ReadByte();
|
||||
int length = binaryReader.Read7BitEncodedInt32();
|
||||
int hashCode = binaryReader.ReadInt32();
|
||||
resources[i] = new LocalVersionList.Resource(name, variant, extension, loadType, length, hashCode);
|
||||
}
|
||||
|
||||
return new LocalVersionList(resources, null);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 反序列化本地版本资源列表(版本 2)回调函数。
|
||||
/// </summary>
|
||||
/// <param name="stream">指定流。</param>
|
||||
/// <returns>反序列化的本地版本资源列表(版本 2)。</returns>
|
||||
public static LocalVersionList LocalVersionListDeserializeCallback_V2(Stream stream)
|
||||
{
|
||||
using (BinaryReader binaryReader = new BinaryReader(stream, Encoding.UTF8))
|
||||
{
|
||||
byte[] encryptBytes = binaryReader.ReadBytes(CachedHashBytesLength);
|
||||
int resourceCount = binaryReader.Read7BitEncodedInt32();
|
||||
LocalVersionList.Resource[] resources = resourceCount > 0 ? new LocalVersionList.Resource[resourceCount] : null;
|
||||
for (int i = 0; i < resourceCount; i++)
|
||||
{
|
||||
string name = binaryReader.ReadEncryptedString(encryptBytes);
|
||||
string variant = binaryReader.ReadEncryptedString(encryptBytes);
|
||||
string extension = binaryReader.ReadEncryptedString(encryptBytes) ?? DefaultExtension;
|
||||
byte loadType = binaryReader.ReadByte();
|
||||
int length = binaryReader.Read7BitEncodedInt32();
|
||||
int hashCode = binaryReader.ReadInt32();
|
||||
resources[i] = new LocalVersionList.Resource(name, variant, extension, loadType, length, hashCode);
|
||||
}
|
||||
|
||||
int fileSystemCount = binaryReader.Read7BitEncodedInt32();
|
||||
LocalVersionList.FileSystem[] fileSystems = fileSystemCount > 0 ? new LocalVersionList.FileSystem[fileSystemCount] : null;
|
||||
for (int i = 0; i < fileSystemCount; i++)
|
||||
{
|
||||
string name = binaryReader.ReadEncryptedString(encryptBytes);
|
||||
int resourceIndexCount = binaryReader.Read7BitEncodedInt32();
|
||||
int[] resourceIndexes = resourceIndexCount > 0 ? new int[resourceIndexCount] : null;
|
||||
for (int j = 0; j < resourceIndexCount; j++)
|
||||
{
|
||||
resourceIndexes[j] = binaryReader.Read7BitEncodedInt32();
|
||||
}
|
||||
|
||||
fileSystems[i] = new LocalVersionList.FileSystem(name, resourceIndexes);
|
||||
}
|
||||
|
||||
return new LocalVersionList(resources, fileSystems);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: df66ad097f961904fb7bca9ea86b226f
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
+135
@@ -0,0 +1,135 @@
|
||||
//------------------------------------------------------------
|
||||
// Game Framework
|
||||
// Copyright © 2013-2021 Jiang Yin. All rights reserved.
|
||||
// Homepage: https://gameframework.cn/
|
||||
// Feedback: mailto:ellan@gameframework.cn
|
||||
//------------------------------------------------------------
|
||||
|
||||
using GameFramework;
|
||||
using GameFramework.Resource;
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Text;
|
||||
|
||||
namespace UnityGameFramework.Runtime
|
||||
{
|
||||
/// <summary>
|
||||
/// 内置版本资源列表序列化器。
|
||||
/// </summary>
|
||||
public static partial class BuiltinVersionListSerializer
|
||||
{
|
||||
/// <summary>
|
||||
/// 序列化本地版本资源列表(版本 0)回调函数。
|
||||
/// </summary>
|
||||
/// <param name="stream">目标流。</param>
|
||||
/// <param name="versionList">要序列化的本地版本资源列表(版本 0)。</param>
|
||||
/// <returns>是否序列化本地版本资源列表(版本 0)成功。</returns>
|
||||
public static bool LocalVersionListSerializeCallback_V0(Stream stream, LocalVersionList versionList)
|
||||
{
|
||||
if (!versionList.IsValid)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
Utility.Random.GetRandomBytes(s_CachedHashBytes);
|
||||
using (BinaryWriter binaryWriter = new BinaryWriter(stream, Encoding.UTF8))
|
||||
{
|
||||
binaryWriter.Write(s_CachedHashBytes);
|
||||
LocalVersionList.Resource[] resources = versionList.GetResources();
|
||||
binaryWriter.Write(resources.Length);
|
||||
foreach (LocalVersionList.Resource resource in resources)
|
||||
{
|
||||
binaryWriter.WriteEncryptedString(resource.Name, s_CachedHashBytes);
|
||||
binaryWriter.WriteEncryptedString(resource.Variant, s_CachedHashBytes);
|
||||
binaryWriter.Write(resource.LoadType);
|
||||
binaryWriter.Write(resource.Length);
|
||||
binaryWriter.Write(resource.HashCode);
|
||||
}
|
||||
}
|
||||
|
||||
Array.Clear(s_CachedHashBytes, 0, CachedHashBytesLength);
|
||||
return true;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 序列化本地版本资源列表(版本 1)回调函数。
|
||||
/// </summary>
|
||||
/// <param name="stream">目标流。</param>
|
||||
/// <param name="versionList">要序列化的本地版本资源列表(版本 1)。</param>
|
||||
/// <returns>是否序列化本地版本资源列表(版本 1)成功。</returns>
|
||||
public static bool LocalVersionListSerializeCallback_V1(Stream stream, LocalVersionList versionList)
|
||||
{
|
||||
if (!versionList.IsValid)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
Utility.Random.GetRandomBytes(s_CachedHashBytes);
|
||||
using (BinaryWriter binaryWriter = new BinaryWriter(stream, Encoding.UTF8))
|
||||
{
|
||||
binaryWriter.Write(s_CachedHashBytes);
|
||||
LocalVersionList.Resource[] resources = versionList.GetResources();
|
||||
binaryWriter.Write7BitEncodedInt32(resources.Length);
|
||||
foreach (LocalVersionList.Resource resource in resources)
|
||||
{
|
||||
binaryWriter.WriteEncryptedString(resource.Name, s_CachedHashBytes);
|
||||
binaryWriter.WriteEncryptedString(resource.Variant, s_CachedHashBytes);
|
||||
binaryWriter.WriteEncryptedString(resource.Extension != DefaultExtension ? resource.Extension : null, s_CachedHashBytes);
|
||||
binaryWriter.Write(resource.LoadType);
|
||||
binaryWriter.Write7BitEncodedInt32(resource.Length);
|
||||
binaryWriter.Write(resource.HashCode);
|
||||
}
|
||||
}
|
||||
|
||||
Array.Clear(s_CachedHashBytes, 0, CachedHashBytesLength);
|
||||
return true;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 序列化本地版本资源列表(版本 2)回调函数。
|
||||
/// </summary>
|
||||
/// <param name="stream">目标流。</param>
|
||||
/// <param name="versionList">要序列化的本地版本资源列表(版本 2)。</param>
|
||||
/// <returns>是否序列化本地版本资源列表(版本 2)成功。</returns>
|
||||
public static bool LocalVersionListSerializeCallback_V2(Stream stream, LocalVersionList versionList)
|
||||
{
|
||||
if (!versionList.IsValid)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
Utility.Random.GetRandomBytes(s_CachedHashBytes);
|
||||
using (BinaryWriter binaryWriter = new BinaryWriter(stream, Encoding.UTF8))
|
||||
{
|
||||
binaryWriter.Write(s_CachedHashBytes);
|
||||
LocalVersionList.Resource[] resources = versionList.GetResources();
|
||||
binaryWriter.Write7BitEncodedInt32(resources.Length);
|
||||
foreach (LocalVersionList.Resource resource in resources)
|
||||
{
|
||||
binaryWriter.WriteEncryptedString(resource.Name, s_CachedHashBytes);
|
||||
binaryWriter.WriteEncryptedString(resource.Variant, s_CachedHashBytes);
|
||||
binaryWriter.WriteEncryptedString(resource.Extension != DefaultExtension ? resource.Extension : null, s_CachedHashBytes);
|
||||
binaryWriter.Write(resource.LoadType);
|
||||
binaryWriter.Write7BitEncodedInt32(resource.Length);
|
||||
binaryWriter.Write(resource.HashCode);
|
||||
}
|
||||
|
||||
LocalVersionList.FileSystem[] fileSystems = versionList.GetFileSystems();
|
||||
binaryWriter.Write7BitEncodedInt32(fileSystems.Length);
|
||||
foreach (LocalVersionList.FileSystem fileSystem in fileSystems)
|
||||
{
|
||||
binaryWriter.WriteEncryptedString(fileSystem.Name, s_CachedHashBytes);
|
||||
int[] resourceIndexes = fileSystem.GetResourceIndexes();
|
||||
binaryWriter.Write7BitEncodedInt32(resourceIndexes.Length);
|
||||
foreach (int resourceIndex in resourceIndexes)
|
||||
{
|
||||
binaryWriter.Write7BitEncodedInt32(resourceIndex);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Array.Clear(s_CachedHashBytes, 0, CachedHashBytesLength);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 7633b95b6d880174bbf537a35e918141
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
+264
@@ -0,0 +1,264 @@
|
||||
//------------------------------------------------------------
|
||||
// Game Framework
|
||||
// Copyright © 2013-2021 Jiang Yin. All rights reserved.
|
||||
// Homepage: https://gameframework.cn/
|
||||
// Feedback: mailto:ellan@gameframework.cn
|
||||
//------------------------------------------------------------
|
||||
|
||||
using GameFramework;
|
||||
using GameFramework.Resource;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Text;
|
||||
|
||||
namespace UnityGameFramework.Runtime
|
||||
{
|
||||
/// <summary>
|
||||
/// 内置版本资源列表序列化器。
|
||||
/// </summary>
|
||||
public static partial class BuiltinVersionListSerializer
|
||||
{
|
||||
/// <summary>
|
||||
/// 反序列化单机模式版本资源列表(版本 0)回调函数。
|
||||
/// </summary>
|
||||
/// <param name="stream">指定流。</param>
|
||||
/// <returns>反序列化的单机模式版本资源列表(版本 0)。</returns>
|
||||
public static PackageVersionList PackageVersionListDeserializeCallback_V0(Stream stream)
|
||||
{
|
||||
using (BinaryReader binaryReader = new BinaryReader(stream, Encoding.UTF8))
|
||||
{
|
||||
byte[] encryptBytes = binaryReader.ReadBytes(CachedHashBytesLength);
|
||||
string applicableGameVersion = binaryReader.ReadEncryptedString(encryptBytes);
|
||||
int internalResourceVersion = binaryReader.ReadInt32();
|
||||
int assetCount = binaryReader.ReadInt32();
|
||||
PackageVersionList.Asset[] assets = assetCount > 0 ? new PackageVersionList.Asset[assetCount] : null;
|
||||
int resourceCount = binaryReader.ReadInt32();
|
||||
PackageVersionList.Resource[] resources = resourceCount > 0 ? new PackageVersionList.Resource[resourceCount] : null;
|
||||
string[][] resourceToAssetNames = new string[resourceCount][];
|
||||
List<KeyValuePair<string, string[]>> assetNameToDependencyAssetNames = new List<KeyValuePair<string, string[]>>(assetCount);
|
||||
for (int i = 0; i < resourceCount; i++)
|
||||
{
|
||||
string name = binaryReader.ReadEncryptedString(encryptBytes);
|
||||
string variant = binaryReader.ReadEncryptedString(encryptBytes);
|
||||
byte loadType = binaryReader.ReadByte();
|
||||
int length = binaryReader.ReadInt32();
|
||||
int hashCode = binaryReader.ReadInt32();
|
||||
Utility.Converter.GetBytes(hashCode, s_CachedHashBytes);
|
||||
|
||||
int assetNameCount = binaryReader.ReadInt32();
|
||||
string[] assetNames = new string[assetNameCount];
|
||||
for (int j = 0; j < assetNameCount; j++)
|
||||
{
|
||||
assetNames[j] = binaryReader.ReadEncryptedString(s_CachedHashBytes);
|
||||
int dependencyAssetNameCount = binaryReader.ReadInt32();
|
||||
string[] dependencyAssetNames = dependencyAssetNameCount > 0 ? new string[dependencyAssetNameCount] : null;
|
||||
for (int k = 0; k < dependencyAssetNameCount; k++)
|
||||
{
|
||||
dependencyAssetNames[k] = binaryReader.ReadEncryptedString(s_CachedHashBytes);
|
||||
}
|
||||
|
||||
assetNameToDependencyAssetNames.Add(new KeyValuePair<string, string[]>(assetNames[j], dependencyAssetNames));
|
||||
}
|
||||
|
||||
resourceToAssetNames[i] = assetNames;
|
||||
resources[i] = new PackageVersionList.Resource(name, variant, null, loadType, length, hashCode, assetNameCount > 0 ? new int[assetNameCount] : null);
|
||||
}
|
||||
|
||||
assetNameToDependencyAssetNames.Sort(AssetNameToDependencyAssetNamesComparer);
|
||||
Array.Clear(s_CachedHashBytes, 0, CachedHashBytesLength);
|
||||
int index = 0;
|
||||
foreach (KeyValuePair<string, string[]> i in assetNameToDependencyAssetNames)
|
||||
{
|
||||
if (i.Value != null)
|
||||
{
|
||||
int[] dependencyAssetIndexes = new int[i.Value.Length];
|
||||
for (int j = 0; j < i.Value.Length; j++)
|
||||
{
|
||||
dependencyAssetIndexes[j] = GetAssetNameIndex(assetNameToDependencyAssetNames, i.Value[j]);
|
||||
}
|
||||
|
||||
assets[index++] = new PackageVersionList.Asset(i.Key, dependencyAssetIndexes);
|
||||
}
|
||||
else
|
||||
{
|
||||
assets[index++] = new PackageVersionList.Asset(i.Key, null);
|
||||
}
|
||||
}
|
||||
|
||||
for (int i = 0; i < resources.Length; i++)
|
||||
{
|
||||
int[] assetIndexes = resources[i].GetAssetIndexes();
|
||||
for (int j = 0; j < assetIndexes.Length; j++)
|
||||
{
|
||||
assetIndexes[j] = GetAssetNameIndex(assetNameToDependencyAssetNames, resourceToAssetNames[i][j]);
|
||||
}
|
||||
}
|
||||
|
||||
int resourceGroupCount = binaryReader.ReadInt32();
|
||||
PackageVersionList.ResourceGroup[] resourceGroups = resourceGroupCount > 0 ? new PackageVersionList.ResourceGroup[resourceGroupCount] : null;
|
||||
for (int i = 0; i < resourceGroupCount; i++)
|
||||
{
|
||||
string name = binaryReader.ReadEncryptedString(encryptBytes);
|
||||
int resourceIndexCount = binaryReader.ReadInt32();
|
||||
int[] resourceIndexes = resourceIndexCount > 0 ? new int[resourceIndexCount] : null;
|
||||
for (int j = 0; j < resourceIndexCount; j++)
|
||||
{
|
||||
resourceIndexes[j] = binaryReader.ReadUInt16();
|
||||
}
|
||||
|
||||
resourceGroups[i] = new PackageVersionList.ResourceGroup(name, resourceIndexes);
|
||||
}
|
||||
|
||||
return new PackageVersionList(applicableGameVersion, internalResourceVersion, assets, resources, null, resourceGroups);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 反序列化单机模式版本资源列表(版本 1)回调函数。
|
||||
/// </summary>
|
||||
/// <param name="stream">指定流。</param>
|
||||
/// <returns>反序列化的单机模式版本资源列表(版本 1)。</returns>
|
||||
public static PackageVersionList PackageVersionListDeserializeCallback_V1(Stream stream)
|
||||
{
|
||||
using (BinaryReader binaryReader = new BinaryReader(stream, Encoding.UTF8))
|
||||
{
|
||||
byte[] encryptBytes = binaryReader.ReadBytes(CachedHashBytesLength);
|
||||
string applicableGameVersion = binaryReader.ReadEncryptedString(encryptBytes);
|
||||
int internalResourceVersion = binaryReader.Read7BitEncodedInt32();
|
||||
int assetCount = binaryReader.Read7BitEncodedInt32();
|
||||
PackageVersionList.Asset[] assets = assetCount > 0 ? new PackageVersionList.Asset[assetCount] : null;
|
||||
for (int i = 0; i < assetCount; i++)
|
||||
{
|
||||
string name = binaryReader.ReadEncryptedString(encryptBytes);
|
||||
int dependencyAssetCount = binaryReader.Read7BitEncodedInt32();
|
||||
int[] dependencyAssetIndexes = dependencyAssetCount > 0 ? new int[dependencyAssetCount] : null;
|
||||
for (int j = 0; j < dependencyAssetCount; j++)
|
||||
{
|
||||
dependencyAssetIndexes[j] = binaryReader.Read7BitEncodedInt32();
|
||||
}
|
||||
|
||||
assets[i] = new PackageVersionList.Asset(name, dependencyAssetIndexes);
|
||||
}
|
||||
|
||||
int resourceCount = binaryReader.Read7BitEncodedInt32();
|
||||
PackageVersionList.Resource[] resources = resourceCount > 0 ? new PackageVersionList.Resource[resourceCount] : null;
|
||||
for (int i = 0; i < resourceCount; i++)
|
||||
{
|
||||
string name = binaryReader.ReadEncryptedString(encryptBytes);
|
||||
string variant = binaryReader.ReadEncryptedString(encryptBytes);
|
||||
string extension = binaryReader.ReadEncryptedString(encryptBytes) ?? DefaultExtension;
|
||||
byte loadType = binaryReader.ReadByte();
|
||||
int length = binaryReader.Read7BitEncodedInt32();
|
||||
int hashCode = binaryReader.ReadInt32();
|
||||
int assetIndexCount = binaryReader.Read7BitEncodedInt32();
|
||||
int[] assetIndexes = assetIndexCount > 0 ? new int[assetIndexCount] : null;
|
||||
for (int j = 0; j < assetIndexCount; j++)
|
||||
{
|
||||
assetIndexes[j] = binaryReader.Read7BitEncodedInt32();
|
||||
}
|
||||
|
||||
resources[i] = new PackageVersionList.Resource(name, variant, extension, loadType, length, hashCode, assetIndexes);
|
||||
}
|
||||
|
||||
int resourceGroupCount = binaryReader.Read7BitEncodedInt32();
|
||||
PackageVersionList.ResourceGroup[] resourceGroups = resourceGroupCount > 0 ? new PackageVersionList.ResourceGroup[resourceGroupCount] : null;
|
||||
for (int i = 0; i < resourceGroupCount; i++)
|
||||
{
|
||||
string name = binaryReader.ReadEncryptedString(encryptBytes);
|
||||
int resourceIndexCount = binaryReader.Read7BitEncodedInt32();
|
||||
int[] resourceIndexes = resourceIndexCount > 0 ? new int[resourceIndexCount] : null;
|
||||
for (int j = 0; j < resourceIndexCount; j++)
|
||||
{
|
||||
resourceIndexes[j] = binaryReader.Read7BitEncodedInt32();
|
||||
}
|
||||
|
||||
resourceGroups[i] = new PackageVersionList.ResourceGroup(name, resourceIndexes);
|
||||
}
|
||||
|
||||
return new PackageVersionList(applicableGameVersion, internalResourceVersion, assets, resources, null, resourceGroups);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 反序列化单机模式版本资源列表(版本 2)回调函数。
|
||||
/// </summary>
|
||||
/// <param name="stream">指定流。</param>
|
||||
/// <returns>反序列化的单机模式版本资源列表(版本 2)。</returns>
|
||||
public static PackageVersionList PackageVersionListDeserializeCallback_V2(Stream stream)
|
||||
{
|
||||
using (BinaryReader binaryReader = new BinaryReader(stream, Encoding.UTF8))
|
||||
{
|
||||
byte[] encryptBytes = binaryReader.ReadBytes(CachedHashBytesLength);
|
||||
string applicableGameVersion = binaryReader.ReadEncryptedString(encryptBytes);
|
||||
int internalResourceVersion = binaryReader.Read7BitEncodedInt32();
|
||||
int assetCount = binaryReader.Read7BitEncodedInt32();
|
||||
PackageVersionList.Asset[] assets = assetCount > 0 ? new PackageVersionList.Asset[assetCount] : null;
|
||||
for (int i = 0; i < assetCount; i++)
|
||||
{
|
||||
string name = binaryReader.ReadEncryptedString(encryptBytes);
|
||||
int dependencyAssetCount = binaryReader.Read7BitEncodedInt32();
|
||||
int[] dependencyAssetIndexes = dependencyAssetCount > 0 ? new int[dependencyAssetCount] : null;
|
||||
for (int j = 0; j < dependencyAssetCount; j++)
|
||||
{
|
||||
dependencyAssetIndexes[j] = binaryReader.Read7BitEncodedInt32();
|
||||
}
|
||||
|
||||
assets[i] = new PackageVersionList.Asset(name, dependencyAssetIndexes);
|
||||
}
|
||||
|
||||
int resourceCount = binaryReader.Read7BitEncodedInt32();
|
||||
PackageVersionList.Resource[] resources = resourceCount > 0 ? new PackageVersionList.Resource[resourceCount] : null;
|
||||
for (int i = 0; i < resourceCount; i++)
|
||||
{
|
||||
string name = binaryReader.ReadEncryptedString(encryptBytes);
|
||||
string variant = binaryReader.ReadEncryptedString(encryptBytes);
|
||||
string extension = binaryReader.ReadEncryptedString(encryptBytes) ?? DefaultExtension;
|
||||
byte loadType = binaryReader.ReadByte();
|
||||
int length = binaryReader.Read7BitEncodedInt32();
|
||||
int hashCode = binaryReader.ReadInt32();
|
||||
int assetIndexCount = binaryReader.Read7BitEncodedInt32();
|
||||
int[] assetIndexes = assetIndexCount > 0 ? new int[assetIndexCount] : null;
|
||||
for (int j = 0; j < assetIndexCount; j++)
|
||||
{
|
||||
assetIndexes[j] = binaryReader.Read7BitEncodedInt32();
|
||||
}
|
||||
|
||||
resources[i] = new PackageVersionList.Resource(name, variant, extension, loadType, length, hashCode, assetIndexes);
|
||||
}
|
||||
|
||||
int fileSystemCount = binaryReader.Read7BitEncodedInt32();
|
||||
PackageVersionList.FileSystem[] fileSystems = fileSystemCount > 0 ? new PackageVersionList.FileSystem[fileSystemCount] : null;
|
||||
for (int i = 0; i < fileSystemCount; i++)
|
||||
{
|
||||
string name = binaryReader.ReadEncryptedString(encryptBytes);
|
||||
int resourceIndexCount = binaryReader.Read7BitEncodedInt32();
|
||||
int[] resourceIndexes = resourceIndexCount > 0 ? new int[resourceIndexCount] : null;
|
||||
for (int j = 0; j < resourceIndexCount; j++)
|
||||
{
|
||||
resourceIndexes[j] = binaryReader.Read7BitEncodedInt32();
|
||||
}
|
||||
|
||||
fileSystems[i] = new PackageVersionList.FileSystem(name, resourceIndexes);
|
||||
}
|
||||
|
||||
int resourceGroupCount = binaryReader.Read7BitEncodedInt32();
|
||||
PackageVersionList.ResourceGroup[] resourceGroups = resourceGroupCount > 0 ? new PackageVersionList.ResourceGroup[resourceGroupCount] : null;
|
||||
for (int i = 0; i < resourceGroupCount; i++)
|
||||
{
|
||||
string name = binaryReader.ReadEncryptedString(encryptBytes);
|
||||
int resourceIndexCount = binaryReader.Read7BitEncodedInt32();
|
||||
int[] resourceIndexes = resourceIndexCount > 0 ? new int[resourceIndexCount] : null;
|
||||
for (int j = 0; j < resourceIndexCount; j++)
|
||||
{
|
||||
resourceIndexes[j] = binaryReader.Read7BitEncodedInt32();
|
||||
}
|
||||
|
||||
resourceGroups[i] = new PackageVersionList.ResourceGroup(name, resourceIndexes);
|
||||
}
|
||||
|
||||
return new PackageVersionList(applicableGameVersion, internalResourceVersion, assets, resources, fileSystems, resourceGroups);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 55d016c3660f4fa458c20847cf59aa16
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
+239
@@ -0,0 +1,239 @@
|
||||
//------------------------------------------------------------
|
||||
// Game Framework
|
||||
// Copyright © 2013-2021 Jiang Yin. All rights reserved.
|
||||
// Homepage: https://gameframework.cn/
|
||||
// Feedback: mailto:ellan@gameframework.cn
|
||||
//------------------------------------------------------------
|
||||
|
||||
using GameFramework;
|
||||
using GameFramework.Resource;
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Text;
|
||||
|
||||
namespace UnityGameFramework.Runtime
|
||||
{
|
||||
/// <summary>
|
||||
/// 内置版本资源列表序列化器。
|
||||
/// </summary>
|
||||
public static partial class BuiltinVersionListSerializer
|
||||
{
|
||||
#if UNITY_EDITOR
|
||||
|
||||
/// <summary>
|
||||
/// 序列化单机模式版本资源列表(版本 0)回调函数。
|
||||
/// </summary>
|
||||
/// <param name="stream">目标流。</param>
|
||||
/// <param name="versionList">要序列化的单机模式版本资源列表(版本 0)。</param>
|
||||
/// <returns>是否序列化单机模式版本资源列表(版本 0)成功。</returns>
|
||||
public static bool PackageVersionListSerializeCallback_V0(Stream stream, PackageVersionList versionList)
|
||||
{
|
||||
if (!versionList.IsValid)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
Utility.Random.GetRandomBytes(s_CachedHashBytes);
|
||||
using (BinaryWriter binaryWriter = new BinaryWriter(stream, Encoding.UTF8))
|
||||
{
|
||||
binaryWriter.Write(s_CachedHashBytes);
|
||||
binaryWriter.WriteEncryptedString(versionList.ApplicableGameVersion, s_CachedHashBytes);
|
||||
binaryWriter.Write(versionList.InternalResourceVersion);
|
||||
PackageVersionList.Asset[] assets = versionList.GetAssets();
|
||||
binaryWriter.Write(assets.Length);
|
||||
PackageVersionList.Resource[] resources = versionList.GetResources();
|
||||
binaryWriter.Write(resources.Length);
|
||||
foreach (PackageVersionList.Resource resource in resources)
|
||||
{
|
||||
binaryWriter.WriteEncryptedString(resource.Name, s_CachedHashBytes);
|
||||
binaryWriter.WriteEncryptedString(resource.Variant, s_CachedHashBytes);
|
||||
binaryWriter.Write(resource.LoadType);
|
||||
binaryWriter.Write(resource.Length);
|
||||
binaryWriter.Write(resource.HashCode);
|
||||
int[] assetIndexes = resource.GetAssetIndexes();
|
||||
binaryWriter.Write(assetIndexes.Length);
|
||||
byte[] hashBytes = new byte[CachedHashBytesLength];
|
||||
foreach (int assetIndex in assetIndexes)
|
||||
{
|
||||
Utility.Converter.GetBytes(resource.HashCode, hashBytes);
|
||||
PackageVersionList.Asset asset = assets[assetIndex];
|
||||
binaryWriter.WriteEncryptedString(asset.Name, hashBytes);
|
||||
int[] dependencyAssetIndexes = asset.GetDependencyAssetIndexes();
|
||||
binaryWriter.Write(dependencyAssetIndexes.Length);
|
||||
foreach (int dependencyAssetIndex in dependencyAssetIndexes)
|
||||
{
|
||||
binaryWriter.WriteEncryptedString(assets[dependencyAssetIndex].Name, hashBytes);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
PackageVersionList.ResourceGroup[] resourceGroups = versionList.GetResourceGroups();
|
||||
binaryWriter.Write(resourceGroups.Length);
|
||||
foreach (PackageVersionList.ResourceGroup resourceGroup in resourceGroups)
|
||||
{
|
||||
binaryWriter.WriteEncryptedString(resourceGroup.Name, s_CachedHashBytes);
|
||||
int[] resourceIndexes = resourceGroup.GetResourceIndexes();
|
||||
binaryWriter.Write(resourceIndexes.Length);
|
||||
foreach (ushort resourceIndex in resourceIndexes)
|
||||
{
|
||||
binaryWriter.Write(resourceIndex);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Array.Clear(s_CachedHashBytes, 0, CachedHashBytesLength);
|
||||
return true;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 序列化单机模式版本资源列表(版本 1)回调函数。
|
||||
/// </summary>
|
||||
/// <param name="stream">目标流。</param>
|
||||
/// <param name="versionList">要序列化的单机模式版本资源列表(版本 1)。</param>
|
||||
/// <returns>是否序列化单机模式版本资源列表(版本 1)成功。</returns>
|
||||
public static bool PackageVersionListSerializeCallback_V1(Stream stream, PackageVersionList versionList)
|
||||
{
|
||||
if (!versionList.IsValid)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
Utility.Random.GetRandomBytes(s_CachedHashBytes);
|
||||
using (BinaryWriter binaryWriter = new BinaryWriter(stream, Encoding.UTF8))
|
||||
{
|
||||
binaryWriter.Write(s_CachedHashBytes);
|
||||
binaryWriter.WriteEncryptedString(versionList.ApplicableGameVersion, s_CachedHashBytes);
|
||||
binaryWriter.Write7BitEncodedInt32(versionList.InternalResourceVersion);
|
||||
PackageVersionList.Asset[] assets = versionList.GetAssets();
|
||||
binaryWriter.Write7BitEncodedInt32(assets.Length);
|
||||
foreach (PackageVersionList.Asset asset in assets)
|
||||
{
|
||||
binaryWriter.WriteEncryptedString(asset.Name, s_CachedHashBytes);
|
||||
int[] dependencyAssetIndexes = asset.GetDependencyAssetIndexes();
|
||||
binaryWriter.Write7BitEncodedInt32(dependencyAssetIndexes.Length);
|
||||
foreach (int dependencyAssetIndex in dependencyAssetIndexes)
|
||||
{
|
||||
binaryWriter.Write7BitEncodedInt32(dependencyAssetIndex);
|
||||
}
|
||||
}
|
||||
|
||||
PackageVersionList.Resource[] resources = versionList.GetResources();
|
||||
binaryWriter.Write7BitEncodedInt32(resources.Length);
|
||||
foreach (PackageVersionList.Resource resource in resources)
|
||||
{
|
||||
binaryWriter.WriteEncryptedString(resource.Name, s_CachedHashBytes);
|
||||
binaryWriter.WriteEncryptedString(resource.Variant, s_CachedHashBytes);
|
||||
binaryWriter.WriteEncryptedString(resource.Extension != DefaultExtension ? resource.Extension : null, s_CachedHashBytes);
|
||||
binaryWriter.Write(resource.LoadType);
|
||||
binaryWriter.Write7BitEncodedInt32(resource.Length);
|
||||
binaryWriter.Write(resource.HashCode);
|
||||
int[] assetIndexes = resource.GetAssetIndexes();
|
||||
binaryWriter.Write7BitEncodedInt32(assetIndexes.Length);
|
||||
foreach (int assetIndex in assetIndexes)
|
||||
{
|
||||
binaryWriter.Write7BitEncodedInt32(assetIndex);
|
||||
}
|
||||
}
|
||||
|
||||
PackageVersionList.ResourceGroup[] resourceGroups = versionList.GetResourceGroups();
|
||||
binaryWriter.Write7BitEncodedInt32(resourceGroups.Length);
|
||||
foreach (PackageVersionList.ResourceGroup resourceGroup in resourceGroups)
|
||||
{
|
||||
binaryWriter.WriteEncryptedString(resourceGroup.Name, s_CachedHashBytes);
|
||||
int[] resourceIndexes = resourceGroup.GetResourceIndexes();
|
||||
binaryWriter.Write7BitEncodedInt32(resourceIndexes.Length);
|
||||
foreach (int resourceIndex in resourceIndexes)
|
||||
{
|
||||
binaryWriter.Write7BitEncodedInt32(resourceIndex);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Array.Clear(s_CachedHashBytes, 0, CachedHashBytesLength);
|
||||
return true;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 序列化单机模式版本资源列表(版本 2)回调函数。
|
||||
/// </summary>
|
||||
/// <param name="stream">目标流。</param>
|
||||
/// <param name="versionList">要序列化的单机模式版本资源列表(版本 2)。</param>
|
||||
/// <returns>是否序列化单机模式版本资源列表(版本 2)成功。</returns>
|
||||
public static bool PackageVersionListSerializeCallback_V2(Stream stream, PackageVersionList versionList)
|
||||
{
|
||||
if (!versionList.IsValid)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
Utility.Random.GetRandomBytes(s_CachedHashBytes);
|
||||
using (BinaryWriter binaryWriter = new BinaryWriter(stream, Encoding.UTF8))
|
||||
{
|
||||
binaryWriter.Write(s_CachedHashBytes);
|
||||
binaryWriter.WriteEncryptedString(versionList.ApplicableGameVersion, s_CachedHashBytes);
|
||||
binaryWriter.Write7BitEncodedInt32(versionList.InternalResourceVersion);
|
||||
PackageVersionList.Asset[] assets = versionList.GetAssets();
|
||||
binaryWriter.Write7BitEncodedInt32(assets.Length);
|
||||
foreach (PackageVersionList.Asset asset in assets)
|
||||
{
|
||||
binaryWriter.WriteEncryptedString(asset.Name, s_CachedHashBytes);
|
||||
int[] dependencyAssetIndexes = asset.GetDependencyAssetIndexes();
|
||||
binaryWriter.Write7BitEncodedInt32(dependencyAssetIndexes.Length);
|
||||
foreach (int dependencyAssetIndex in dependencyAssetIndexes)
|
||||
{
|
||||
binaryWriter.Write7BitEncodedInt32(dependencyAssetIndex);
|
||||
}
|
||||
}
|
||||
|
||||
PackageVersionList.Resource[] resources = versionList.GetResources();
|
||||
binaryWriter.Write7BitEncodedInt32(resources.Length);
|
||||
foreach (PackageVersionList.Resource resource in resources)
|
||||
{
|
||||
binaryWriter.WriteEncryptedString(resource.Name, s_CachedHashBytes);
|
||||
binaryWriter.WriteEncryptedString(resource.Variant, s_CachedHashBytes);
|
||||
binaryWriter.WriteEncryptedString(resource.Extension != DefaultExtension ? resource.Extension : null, s_CachedHashBytes);
|
||||
binaryWriter.Write(resource.LoadType);
|
||||
binaryWriter.Write7BitEncodedInt32(resource.Length);
|
||||
binaryWriter.Write(resource.HashCode);
|
||||
int[] assetIndexes = resource.GetAssetIndexes();
|
||||
binaryWriter.Write7BitEncodedInt32(assetIndexes.Length);
|
||||
foreach (int assetIndex in assetIndexes)
|
||||
{
|
||||
binaryWriter.Write7BitEncodedInt32(assetIndex);
|
||||
}
|
||||
}
|
||||
|
||||
PackageVersionList.FileSystem[] fileSystems = versionList.GetFileSystems();
|
||||
binaryWriter.Write7BitEncodedInt32(fileSystems.Length);
|
||||
foreach (PackageVersionList.FileSystem fileSystem in fileSystems)
|
||||
{
|
||||
binaryWriter.WriteEncryptedString(fileSystem.Name, s_CachedHashBytes);
|
||||
int[] resourceIndexes = fileSystem.GetResourceIndexes();
|
||||
binaryWriter.Write7BitEncodedInt32(resourceIndexes.Length);
|
||||
foreach (int resourceIndex in resourceIndexes)
|
||||
{
|
||||
binaryWriter.Write7BitEncodedInt32(resourceIndex);
|
||||
}
|
||||
}
|
||||
|
||||
PackageVersionList.ResourceGroup[] resourceGroups = versionList.GetResourceGroups();
|
||||
binaryWriter.Write7BitEncodedInt32(resourceGroups.Length);
|
||||
foreach (PackageVersionList.ResourceGroup resourceGroup in resourceGroups)
|
||||
{
|
||||
binaryWriter.WriteEncryptedString(resourceGroup.Name, s_CachedHashBytes);
|
||||
int[] resourceIndexes = resourceGroup.GetResourceIndexes();
|
||||
binaryWriter.Write7BitEncodedInt32(resourceIndexes.Length);
|
||||
foreach (int resourceIndex in resourceIndexes)
|
||||
{
|
||||
binaryWriter.Write7BitEncodedInt32(resourceIndex);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Array.Clear(s_CachedHashBytes, 0, CachedHashBytesLength);
|
||||
return true;
|
||||
}
|
||||
|
||||
#endif
|
||||
}
|
||||
}
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 3f1e0304275244949890ac3aa8a7f236
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
+52
@@ -0,0 +1,52 @@
|
||||
//------------------------------------------------------------
|
||||
// Game Framework
|
||||
// Copyright © 2013-2021 Jiang Yin. All rights reserved.
|
||||
// Homepage: https://gameframework.cn/
|
||||
// Feedback: mailto:ellan@gameframework.cn
|
||||
//------------------------------------------------------------
|
||||
|
||||
using GameFramework.Resource;
|
||||
using System.IO;
|
||||
using System.Text;
|
||||
|
||||
namespace UnityGameFramework.Runtime
|
||||
{
|
||||
/// <summary>
|
||||
/// 内置版本资源列表序列化器。
|
||||
/// </summary>
|
||||
public static partial class BuiltinVersionListSerializer
|
||||
{
|
||||
/// <summary>
|
||||
/// 反序列化资源包版本资源列表(版本 0)回调函数。
|
||||
/// </summary>
|
||||
/// <param name="stream">指定流。</param>
|
||||
/// <returns>反序列化的资源包版本资源列表(版本 0)。</returns>
|
||||
public static ResourcePackVersionList ResourcePackVersionListDeserializeCallback_V0(Stream stream)
|
||||
{
|
||||
using (BinaryReader binaryReader = new BinaryReader(stream, Encoding.UTF8))
|
||||
{
|
||||
byte[] encryptBytes = binaryReader.ReadBytes(CachedHashBytesLength);
|
||||
int dataOffset = binaryReader.ReadInt32();
|
||||
long dataLength = binaryReader.ReadInt64();
|
||||
int dataHashCode = binaryReader.ReadInt32();
|
||||
int resourceCount = binaryReader.Read7BitEncodedInt32();
|
||||
ResourcePackVersionList.Resource[] resources = resourceCount > 0 ? new ResourcePackVersionList.Resource[resourceCount] : null;
|
||||
for (int i = 0; i < resourceCount; i++)
|
||||
{
|
||||
string name = binaryReader.ReadEncryptedString(encryptBytes);
|
||||
string variant = binaryReader.ReadEncryptedString(encryptBytes);
|
||||
string extension = binaryReader.ReadEncryptedString(encryptBytes) ?? DefaultExtension;
|
||||
byte loadType = binaryReader.ReadByte();
|
||||
long offset = binaryReader.Read7BitEncodedInt64();
|
||||
int length = binaryReader.Read7BitEncodedInt32();
|
||||
int hashCode = binaryReader.ReadInt32();
|
||||
int compressedLength = binaryReader.Read7BitEncodedInt32();
|
||||
int compressedHashCode = binaryReader.ReadInt32();
|
||||
resources[i] = new ResourcePackVersionList.Resource(name, variant, extension, loadType, offset, length, hashCode, compressedLength, compressedHashCode);
|
||||
}
|
||||
|
||||
return new ResourcePackVersionList(dataOffset, dataLength, dataHashCode, resources);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 03b37f88eb002e740881c81bba3ac02b
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
+65
@@ -0,0 +1,65 @@
|
||||
//------------------------------------------------------------
|
||||
// Game Framework
|
||||
// Copyright © 2013-2021 Jiang Yin. All rights reserved.
|
||||
// Homepage: https://gameframework.cn/
|
||||
// Feedback: mailto:ellan@gameframework.cn
|
||||
//------------------------------------------------------------
|
||||
|
||||
using GameFramework;
|
||||
using GameFramework.Resource;
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Text;
|
||||
|
||||
namespace UnityGameFramework.Runtime
|
||||
{
|
||||
/// <summary>
|
||||
/// 内置版本资源列表序列化器。
|
||||
/// </summary>
|
||||
public static partial class BuiltinVersionListSerializer
|
||||
{
|
||||
#if UNITY_EDITOR
|
||||
|
||||
/// <summary>
|
||||
/// 序列化资源包版本资源列表(版本 0)回调函数。
|
||||
/// </summary>
|
||||
/// <param name="stream">目标流。</param>
|
||||
/// <param name="versionList">要序列化的资源包版本资源列表(版本 0)。</param>
|
||||
/// <returns>是否序列化资源包版本资源列表(版本 0)成功。</returns>
|
||||
public static bool ResourcePackVersionListSerializeCallback_V0(Stream stream, ResourcePackVersionList versionList)
|
||||
{
|
||||
if (!versionList.IsValid)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
Utility.Random.GetRandomBytes(s_CachedHashBytes);
|
||||
using (BinaryWriter binaryWriter = new BinaryWriter(stream, Encoding.UTF8))
|
||||
{
|
||||
binaryWriter.Write(s_CachedHashBytes);
|
||||
binaryWriter.Write(versionList.Offset);
|
||||
binaryWriter.Write(versionList.Length);
|
||||
binaryWriter.Write(versionList.HashCode);
|
||||
ResourcePackVersionList.Resource[] resources = versionList.GetResources();
|
||||
binaryWriter.Write7BitEncodedInt32(resources.Length);
|
||||
foreach (ResourcePackVersionList.Resource resource in resources)
|
||||
{
|
||||
binaryWriter.WriteEncryptedString(resource.Name, s_CachedHashBytes);
|
||||
binaryWriter.WriteEncryptedString(resource.Variant, s_CachedHashBytes);
|
||||
binaryWriter.WriteEncryptedString(resource.Extension != DefaultExtension ? resource.Extension : null, s_CachedHashBytes);
|
||||
binaryWriter.Write(resource.LoadType);
|
||||
binaryWriter.Write7BitEncodedInt64(resource.Offset);
|
||||
binaryWriter.Write7BitEncodedInt32(resource.Length);
|
||||
binaryWriter.Write(resource.HashCode);
|
||||
binaryWriter.Write7BitEncodedInt32(resource.CompressedLength);
|
||||
binaryWriter.Write(resource.CompressedHashCode);
|
||||
}
|
||||
}
|
||||
|
||||
Array.Clear(s_CachedHashBytes, 0, CachedHashBytesLength);
|
||||
return true;
|
||||
}
|
||||
|
||||
#endif
|
||||
}
|
||||
}
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 8bff196dc370ba048b548e0be53dc26f
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
+270
@@ -0,0 +1,270 @@
|
||||
//------------------------------------------------------------
|
||||
// Game Framework
|
||||
// Copyright © 2013-2021 Jiang Yin. All rights reserved.
|
||||
// Homepage: https://gameframework.cn/
|
||||
// Feedback: mailto:ellan@gameframework.cn
|
||||
//------------------------------------------------------------
|
||||
|
||||
using GameFramework;
|
||||
using GameFramework.Resource;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Text;
|
||||
|
||||
namespace UnityGameFramework.Runtime
|
||||
{
|
||||
/// <summary>
|
||||
/// 内置版本资源列表序列化器。
|
||||
/// </summary>
|
||||
public static partial class BuiltinVersionListSerializer
|
||||
{
|
||||
/// <summary>
|
||||
/// 反序列化可更新模式版本资源列表(版本 0)回调函数。
|
||||
/// </summary>
|
||||
/// <param name="stream">指定流。</param>
|
||||
/// <returns>反序列化的可更新模式版本资源列表(版本 0)。</returns>
|
||||
public static UpdatableVersionList UpdatableVersionListDeserializeCallback_V0(Stream stream)
|
||||
{
|
||||
using (BinaryReader binaryReader = new BinaryReader(stream, Encoding.UTF8))
|
||||
{
|
||||
byte[] encryptBytes = binaryReader.ReadBytes(CachedHashBytesLength);
|
||||
string applicableGameVersion = binaryReader.ReadEncryptedString(encryptBytes);
|
||||
int internalResourceVersion = binaryReader.ReadInt32();
|
||||
int assetCount = binaryReader.ReadInt32();
|
||||
UpdatableVersionList.Asset[] assets = assetCount > 0 ? new UpdatableVersionList.Asset[assetCount] : null;
|
||||
int resourceCount = binaryReader.ReadInt32();
|
||||
UpdatableVersionList.Resource[] resources = resourceCount > 0 ? new UpdatableVersionList.Resource[resourceCount] : null;
|
||||
string[][] resourceToAssetNames = new string[resourceCount][];
|
||||
List<KeyValuePair<string, string[]>> assetNameToDependencyAssetNames = new List<KeyValuePair<string, string[]>>(assetCount);
|
||||
for (int i = 0; i < resourceCount; i++)
|
||||
{
|
||||
string name = binaryReader.ReadEncryptedString(encryptBytes);
|
||||
string variant = binaryReader.ReadEncryptedString(encryptBytes);
|
||||
byte loadType = binaryReader.ReadByte();
|
||||
int length = binaryReader.ReadInt32();
|
||||
int hashCode = binaryReader.ReadInt32();
|
||||
int compressedLength = binaryReader.ReadInt32();
|
||||
int compressedHashCode = binaryReader.ReadInt32();
|
||||
Utility.Converter.GetBytes(hashCode, s_CachedHashBytes);
|
||||
|
||||
int assetNameCount = binaryReader.ReadInt32();
|
||||
string[] assetNames = assetNameCount > 0 ? new string[assetNameCount] : null;
|
||||
for (int j = 0; j < assetNameCount; j++)
|
||||
{
|
||||
assetNames[j] = binaryReader.ReadEncryptedString(s_CachedHashBytes);
|
||||
int dependencyAssetNameCount = binaryReader.ReadInt32();
|
||||
string[] dependencyAssetNames = dependencyAssetNameCount > 0 ? new string[dependencyAssetNameCount] : null;
|
||||
for (int k = 0; k < dependencyAssetNameCount; k++)
|
||||
{
|
||||
dependencyAssetNames[k] = binaryReader.ReadEncryptedString(s_CachedHashBytes);
|
||||
}
|
||||
|
||||
assetNameToDependencyAssetNames.Add(new KeyValuePair<string, string[]>(assetNames[j], dependencyAssetNames));
|
||||
}
|
||||
|
||||
resourceToAssetNames[i] = assetNames;
|
||||
resources[i] = new UpdatableVersionList.Resource(name, variant, null, loadType, length, hashCode, compressedLength, compressedHashCode, assetNameCount > 0 ? new int[assetNameCount] : null);
|
||||
}
|
||||
|
||||
assetNameToDependencyAssetNames.Sort(AssetNameToDependencyAssetNamesComparer);
|
||||
Array.Clear(s_CachedHashBytes, 0, CachedHashBytesLength);
|
||||
int index = 0;
|
||||
foreach (KeyValuePair<string, string[]> i in assetNameToDependencyAssetNames)
|
||||
{
|
||||
if (i.Value != null)
|
||||
{
|
||||
int[] dependencyAssetIndexes = new int[i.Value.Length];
|
||||
for (int j = 0; j < i.Value.Length; j++)
|
||||
{
|
||||
dependencyAssetIndexes[j] = GetAssetNameIndex(assetNameToDependencyAssetNames, i.Value[j]);
|
||||
}
|
||||
|
||||
assets[index++] = new UpdatableVersionList.Asset(i.Key, dependencyAssetIndexes);
|
||||
}
|
||||
else
|
||||
{
|
||||
assets[index++] = new UpdatableVersionList.Asset(i.Key, null);
|
||||
}
|
||||
}
|
||||
|
||||
for (int i = 0; i < resources.Length; i++)
|
||||
{
|
||||
int[] assetIndexes = resources[i].GetAssetIndexes();
|
||||
for (int j = 0; j < assetIndexes.Length; j++)
|
||||
{
|
||||
assetIndexes[j] = GetAssetNameIndex(assetNameToDependencyAssetNames, resourceToAssetNames[i][j]);
|
||||
}
|
||||
}
|
||||
|
||||
int resourceGroupCount = binaryReader.ReadInt32();
|
||||
UpdatableVersionList.ResourceGroup[] resourceGroups = resourceGroupCount > 0 ? new UpdatableVersionList.ResourceGroup[resourceGroupCount] : null;
|
||||
for (int i = 0; i < resourceGroupCount; i++)
|
||||
{
|
||||
string name = binaryReader.ReadEncryptedString(encryptBytes);
|
||||
int resourceIndexCount = binaryReader.ReadInt32();
|
||||
int[] resourceIndexes = resourceIndexCount > 0 ? new int[resourceIndexCount] : null;
|
||||
for (int j = 0; j < resourceIndexCount; j++)
|
||||
{
|
||||
resourceIndexes[j] = binaryReader.ReadUInt16();
|
||||
}
|
||||
|
||||
resourceGroups[i] = new UpdatableVersionList.ResourceGroup(name, resourceIndexes);
|
||||
}
|
||||
|
||||
return new UpdatableVersionList(applicableGameVersion, internalResourceVersion, assets, resources, null, resourceGroups);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 反序列化可更新模式版本资源列表(版本 1)回调函数。
|
||||
/// </summary>
|
||||
/// <param name="stream">指定流。</param>
|
||||
/// <returns>反序列化的可更新模式版本资源列表(版本 1)。</returns>
|
||||
public static UpdatableVersionList UpdatableVersionListDeserializeCallback_V1(Stream stream)
|
||||
{
|
||||
using (BinaryReader binaryReader = new BinaryReader(stream, Encoding.UTF8))
|
||||
{
|
||||
byte[] encryptBytes = binaryReader.ReadBytes(CachedHashBytesLength);
|
||||
string applicableGameVersion = binaryReader.ReadEncryptedString(encryptBytes);
|
||||
int internalResourceVersion = binaryReader.Read7BitEncodedInt32();
|
||||
int assetCount = binaryReader.Read7BitEncodedInt32();
|
||||
UpdatableVersionList.Asset[] assets = assetCount > 0 ? new UpdatableVersionList.Asset[assetCount] : null;
|
||||
for (int i = 0; i < assetCount; i++)
|
||||
{
|
||||
string name = binaryReader.ReadEncryptedString(encryptBytes);
|
||||
int dependencyAssetCount = binaryReader.Read7BitEncodedInt32();
|
||||
int[] dependencyAssetIndexes = dependencyAssetCount > 0 ? new int[dependencyAssetCount] : null;
|
||||
for (int j = 0; j < dependencyAssetCount; j++)
|
||||
{
|
||||
dependencyAssetIndexes[j] = binaryReader.Read7BitEncodedInt32();
|
||||
}
|
||||
|
||||
assets[i] = new UpdatableVersionList.Asset(name, dependencyAssetIndexes);
|
||||
}
|
||||
|
||||
int resourceCount = binaryReader.Read7BitEncodedInt32();
|
||||
UpdatableVersionList.Resource[] resources = resourceCount > 0 ? new UpdatableVersionList.Resource[resourceCount] : null;
|
||||
for (int i = 0; i < resourceCount; i++)
|
||||
{
|
||||
string name = binaryReader.ReadEncryptedString(encryptBytes);
|
||||
string variant = binaryReader.ReadEncryptedString(encryptBytes);
|
||||
string extension = binaryReader.ReadEncryptedString(encryptBytes) ?? DefaultExtension;
|
||||
byte loadType = binaryReader.ReadByte();
|
||||
int length = binaryReader.Read7BitEncodedInt32();
|
||||
int hashCode = binaryReader.ReadInt32();
|
||||
int compressedLength = binaryReader.Read7BitEncodedInt32();
|
||||
int compressedHashCode = binaryReader.ReadInt32();
|
||||
int assetIndexCount = binaryReader.Read7BitEncodedInt32();
|
||||
int[] assetIndexes = assetIndexCount > 0 ? new int[assetIndexCount] : null;
|
||||
for (int j = 0; j < assetIndexCount; j++)
|
||||
{
|
||||
assetIndexes[j] = binaryReader.Read7BitEncodedInt32();
|
||||
}
|
||||
|
||||
resources[i] = new UpdatableVersionList.Resource(name, variant, extension, loadType, length, hashCode, compressedLength, compressedHashCode, assetIndexes);
|
||||
}
|
||||
|
||||
int resourceGroupCount = binaryReader.Read7BitEncodedInt32();
|
||||
UpdatableVersionList.ResourceGroup[] resourceGroups = resourceGroupCount > 0 ? new UpdatableVersionList.ResourceGroup[resourceGroupCount] : null;
|
||||
for (int i = 0; i < resourceGroupCount; i++)
|
||||
{
|
||||
string name = binaryReader.ReadEncryptedString(encryptBytes);
|
||||
int resourceIndexCount = binaryReader.Read7BitEncodedInt32();
|
||||
int[] resourceIndexes = resourceIndexCount > 0 ? new int[resourceIndexCount] : null;
|
||||
for (int j = 0; j < resourceIndexCount; j++)
|
||||
{
|
||||
resourceIndexes[j] = binaryReader.Read7BitEncodedInt32();
|
||||
}
|
||||
|
||||
resourceGroups[i] = new UpdatableVersionList.ResourceGroup(name, resourceIndexes);
|
||||
}
|
||||
|
||||
return new UpdatableVersionList(applicableGameVersion, internalResourceVersion, assets, resources, null, resourceGroups);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 反序列化可更新模式版本资源列表(版本 2)回调函数。
|
||||
/// </summary>
|
||||
/// <param name="stream">指定流。</param>
|
||||
/// <returns>反序列化的可更新模式版本资源列表(版本 2)。</returns>
|
||||
public static UpdatableVersionList UpdatableVersionListDeserializeCallback_V2(Stream stream)
|
||||
{
|
||||
using (BinaryReader binaryReader = new BinaryReader(stream, Encoding.UTF8))
|
||||
{
|
||||
byte[] encryptBytes = binaryReader.ReadBytes(CachedHashBytesLength);
|
||||
string applicableGameVersion = binaryReader.ReadEncryptedString(encryptBytes);
|
||||
int internalResourceVersion = binaryReader.Read7BitEncodedInt32();
|
||||
int assetCount = binaryReader.Read7BitEncodedInt32();
|
||||
UpdatableVersionList.Asset[] assets = assetCount > 0 ? new UpdatableVersionList.Asset[assetCount] : null;
|
||||
for (int i = 0; i < assetCount; i++)
|
||||
{
|
||||
string name = binaryReader.ReadEncryptedString(encryptBytes);
|
||||
int dependencyAssetCount = binaryReader.Read7BitEncodedInt32();
|
||||
int[] dependencyAssetIndexes = dependencyAssetCount > 0 ? new int[dependencyAssetCount] : null;
|
||||
for (int j = 0; j < dependencyAssetCount; j++)
|
||||
{
|
||||
dependencyAssetIndexes[j] = binaryReader.Read7BitEncodedInt32();
|
||||
}
|
||||
|
||||
assets[i] = new UpdatableVersionList.Asset(name, dependencyAssetIndexes);
|
||||
}
|
||||
|
||||
int resourceCount = binaryReader.Read7BitEncodedInt32();
|
||||
UpdatableVersionList.Resource[] resources = resourceCount > 0 ? new UpdatableVersionList.Resource[resourceCount] : null;
|
||||
for (int i = 0; i < resourceCount; i++)
|
||||
{
|
||||
string name = binaryReader.ReadEncryptedString(encryptBytes);
|
||||
string variant = binaryReader.ReadEncryptedString(encryptBytes);
|
||||
string extension = binaryReader.ReadEncryptedString(encryptBytes) ?? DefaultExtension;
|
||||
byte loadType = binaryReader.ReadByte();
|
||||
int length = binaryReader.Read7BitEncodedInt32();
|
||||
int hashCode = binaryReader.ReadInt32();
|
||||
int compressedLength = binaryReader.Read7BitEncodedInt32();
|
||||
int compressedHashCode = binaryReader.ReadInt32();
|
||||
int assetIndexCount = binaryReader.Read7BitEncodedInt32();
|
||||
int[] assetIndexes = assetIndexCount > 0 ? new int[assetIndexCount] : null;
|
||||
for (int j = 0; j < assetIndexCount; j++)
|
||||
{
|
||||
assetIndexes[j] = binaryReader.Read7BitEncodedInt32();
|
||||
}
|
||||
|
||||
resources[i] = new UpdatableVersionList.Resource(name, variant, extension, loadType, length, hashCode, compressedLength, compressedHashCode, assetIndexes);
|
||||
}
|
||||
|
||||
int fileSystemCount = binaryReader.Read7BitEncodedInt32();
|
||||
UpdatableVersionList.FileSystem[] fileSystems = fileSystemCount > 0 ? new UpdatableVersionList.FileSystem[fileSystemCount] : null;
|
||||
for (int i = 0; i < fileSystemCount; i++)
|
||||
{
|
||||
string name = binaryReader.ReadEncryptedString(encryptBytes);
|
||||
int resourceIndexCount = binaryReader.Read7BitEncodedInt32();
|
||||
int[] resourceIndexes = resourceIndexCount > 0 ? new int[resourceIndexCount] : null;
|
||||
for (int j = 0; j < resourceIndexCount; j++)
|
||||
{
|
||||
resourceIndexes[j] = binaryReader.Read7BitEncodedInt32();
|
||||
}
|
||||
|
||||
fileSystems[i] = new UpdatableVersionList.FileSystem(name, resourceIndexes);
|
||||
}
|
||||
|
||||
int resourceGroupCount = binaryReader.Read7BitEncodedInt32();
|
||||
UpdatableVersionList.ResourceGroup[] resourceGroups = resourceGroupCount > 0 ? new UpdatableVersionList.ResourceGroup[resourceGroupCount] : null;
|
||||
for (int i = 0; i < resourceGroupCount; i++)
|
||||
{
|
||||
string name = binaryReader.ReadEncryptedString(encryptBytes);
|
||||
int resourceIndexCount = binaryReader.Read7BitEncodedInt32();
|
||||
int[] resourceIndexes = resourceIndexCount > 0 ? new int[resourceIndexCount] : null;
|
||||
for (int j = 0; j < resourceIndexCount; j++)
|
||||
{
|
||||
resourceIndexes[j] = binaryReader.Read7BitEncodedInt32();
|
||||
}
|
||||
|
||||
resourceGroups[i] = new UpdatableVersionList.ResourceGroup(name, resourceIndexes);
|
||||
}
|
||||
|
||||
return new UpdatableVersionList(applicableGameVersion, internalResourceVersion, assets, resources, fileSystems, resourceGroups);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: f8075a91786219b4db1b77aa406a81e8
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
+245
@@ -0,0 +1,245 @@
|
||||
//------------------------------------------------------------
|
||||
// Game Framework
|
||||
// Copyright © 2013-2021 Jiang Yin. All rights reserved.
|
||||
// Homepage: https://gameframework.cn/
|
||||
// Feedback: mailto:ellan@gameframework.cn
|
||||
//------------------------------------------------------------
|
||||
|
||||
using GameFramework;
|
||||
using GameFramework.Resource;
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Text;
|
||||
|
||||
namespace UnityGameFramework.Runtime
|
||||
{
|
||||
/// <summary>
|
||||
/// 内置版本资源列表序列化器。
|
||||
/// </summary>
|
||||
public static partial class BuiltinVersionListSerializer
|
||||
{
|
||||
#if UNITY_EDITOR
|
||||
|
||||
/// <summary>
|
||||
/// 序列化可更新模式版本资源列表(版本 0)回调函数。
|
||||
/// </summary>
|
||||
/// <param name="stream">目标流。</param>
|
||||
/// <param name="versionList">要序列化的可更新模式版本资源列表(版本 0)。</param>
|
||||
/// <returns>是否序列化可更新模式版本资源列表(版本 0)成功。</returns>
|
||||
public static bool UpdatableVersionListSerializeCallback_V0(Stream stream, UpdatableVersionList versionList)
|
||||
{
|
||||
if (!versionList.IsValid)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
Utility.Random.GetRandomBytes(s_CachedHashBytes);
|
||||
using (BinaryWriter binaryWriter = new BinaryWriter(stream, Encoding.UTF8))
|
||||
{
|
||||
binaryWriter.Write(s_CachedHashBytes);
|
||||
binaryWriter.WriteEncryptedString(versionList.ApplicableGameVersion, s_CachedHashBytes);
|
||||
binaryWriter.Write(versionList.InternalResourceVersion);
|
||||
UpdatableVersionList.Asset[] assets = versionList.GetAssets();
|
||||
binaryWriter.Write(assets.Length);
|
||||
UpdatableVersionList.Resource[] resources = versionList.GetResources();
|
||||
binaryWriter.Write(resources.Length);
|
||||
foreach (UpdatableVersionList.Resource resource in resources)
|
||||
{
|
||||
binaryWriter.WriteEncryptedString(resource.Name, s_CachedHashBytes);
|
||||
binaryWriter.WriteEncryptedString(resource.Variant, s_CachedHashBytes);
|
||||
binaryWriter.Write(resource.LoadType);
|
||||
binaryWriter.Write(resource.Length);
|
||||
binaryWriter.Write(resource.HashCode);
|
||||
binaryWriter.Write(resource.CompressedLength);
|
||||
binaryWriter.Write(resource.CompressedHashCode);
|
||||
int[] assetIndexes = resource.GetAssetIndexes();
|
||||
binaryWriter.Write(assetIndexes.Length);
|
||||
byte[] hashBytes = new byte[CachedHashBytesLength];
|
||||
foreach (int assetIndex in assetIndexes)
|
||||
{
|
||||
Utility.Converter.GetBytes(resource.HashCode, hashBytes);
|
||||
UpdatableVersionList.Asset asset = assets[assetIndex];
|
||||
binaryWriter.WriteEncryptedString(asset.Name, hashBytes);
|
||||
int[] dependencyAssetIndexes = asset.GetDependencyAssetIndexes();
|
||||
binaryWriter.Write(dependencyAssetIndexes.Length);
|
||||
foreach (int dependencyAssetIndex in dependencyAssetIndexes)
|
||||
{
|
||||
binaryWriter.WriteEncryptedString(assets[dependencyAssetIndex].Name, hashBytes);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
UpdatableVersionList.ResourceGroup[] resourceGroups = versionList.GetResourceGroups();
|
||||
binaryWriter.Write(resourceGroups.Length);
|
||||
foreach (UpdatableVersionList.ResourceGroup resourceGroup in resourceGroups)
|
||||
{
|
||||
binaryWriter.WriteEncryptedString(resourceGroup.Name, s_CachedHashBytes);
|
||||
int[] resourceIndexes = resourceGroup.GetResourceIndexes();
|
||||
binaryWriter.Write(resourceIndexes.Length);
|
||||
foreach (ushort resourceIndex in resourceIndexes)
|
||||
{
|
||||
binaryWriter.Write(resourceIndex);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Array.Clear(s_CachedHashBytes, 0, CachedHashBytesLength);
|
||||
return true;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 序列化可更新模式版本资源列表(版本 1)回调函数。
|
||||
/// </summary>
|
||||
/// <param name="stream">目标流。</param>
|
||||
/// <param name="versionList">要序列化的可更新模式版本资源列表(版本 1)。</param>
|
||||
/// <returns>是否序列化可更新模式版本资源列表(版本 1)成功。</returns>
|
||||
public static bool UpdatableVersionListSerializeCallback_V1(Stream stream, UpdatableVersionList versionList)
|
||||
{
|
||||
if (!versionList.IsValid)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
Utility.Random.GetRandomBytes(s_CachedHashBytes);
|
||||
using (BinaryWriter binaryWriter = new BinaryWriter(stream, Encoding.UTF8))
|
||||
{
|
||||
binaryWriter.Write(s_CachedHashBytes);
|
||||
binaryWriter.WriteEncryptedString(versionList.ApplicableGameVersion, s_CachedHashBytes);
|
||||
binaryWriter.Write7BitEncodedInt32(versionList.InternalResourceVersion);
|
||||
UpdatableVersionList.Asset[] assets = versionList.GetAssets();
|
||||
binaryWriter.Write7BitEncodedInt32(assets.Length);
|
||||
foreach (UpdatableVersionList.Asset asset in assets)
|
||||
{
|
||||
binaryWriter.WriteEncryptedString(asset.Name, s_CachedHashBytes);
|
||||
int[] dependencyAssetIndexes = asset.GetDependencyAssetIndexes();
|
||||
binaryWriter.Write7BitEncodedInt32(dependencyAssetIndexes.Length);
|
||||
foreach (int dependencyAssetIndex in dependencyAssetIndexes)
|
||||
{
|
||||
binaryWriter.Write7BitEncodedInt32(dependencyAssetIndex);
|
||||
}
|
||||
}
|
||||
|
||||
UpdatableVersionList.Resource[] resources = versionList.GetResources();
|
||||
binaryWriter.Write7BitEncodedInt32(resources.Length);
|
||||
foreach (UpdatableVersionList.Resource resource in resources)
|
||||
{
|
||||
binaryWriter.WriteEncryptedString(resource.Name, s_CachedHashBytes);
|
||||
binaryWriter.WriteEncryptedString(resource.Variant, s_CachedHashBytes);
|
||||
binaryWriter.WriteEncryptedString(resource.Extension != DefaultExtension ? resource.Extension : null, s_CachedHashBytes);
|
||||
binaryWriter.Write(resource.LoadType);
|
||||
binaryWriter.Write7BitEncodedInt32(resource.Length);
|
||||
binaryWriter.Write(resource.HashCode);
|
||||
binaryWriter.Write7BitEncodedInt32(resource.CompressedLength);
|
||||
binaryWriter.Write(resource.CompressedHashCode);
|
||||
int[] assetIndexes = resource.GetAssetIndexes();
|
||||
binaryWriter.Write7BitEncodedInt32(assetIndexes.Length);
|
||||
foreach (int assetIndex in assetIndexes)
|
||||
{
|
||||
binaryWriter.Write7BitEncodedInt32(assetIndex);
|
||||
}
|
||||
}
|
||||
|
||||
UpdatableVersionList.ResourceGroup[] resourceGroups = versionList.GetResourceGroups();
|
||||
binaryWriter.Write7BitEncodedInt32(resourceGroups.Length);
|
||||
foreach (UpdatableVersionList.ResourceGroup resourceGroup in resourceGroups)
|
||||
{
|
||||
binaryWriter.WriteEncryptedString(resourceGroup.Name, s_CachedHashBytes);
|
||||
int[] resourceIndexes = resourceGroup.GetResourceIndexes();
|
||||
binaryWriter.Write7BitEncodedInt32(resourceIndexes.Length);
|
||||
foreach (int resourceIndex in resourceIndexes)
|
||||
{
|
||||
binaryWriter.Write7BitEncodedInt32(resourceIndex);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Array.Clear(s_CachedHashBytes, 0, CachedHashBytesLength);
|
||||
return true;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 序列化可更新模式版本资源列表(版本 2)回调函数。
|
||||
/// </summary>
|
||||
/// <param name="stream">目标流。</param>
|
||||
/// <param name="versionList">要序列化的可更新模式版本资源列表(版本 2)。</param>
|
||||
/// <returns>是否序列化可更新模式版本资源列表(版本 2)成功。</returns>
|
||||
public static bool UpdatableVersionListSerializeCallback_V2(Stream stream, UpdatableVersionList versionList)
|
||||
{
|
||||
if (!versionList.IsValid)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
Utility.Random.GetRandomBytes(s_CachedHashBytes);
|
||||
using (BinaryWriter binaryWriter = new BinaryWriter(stream, Encoding.UTF8))
|
||||
{
|
||||
binaryWriter.Write(s_CachedHashBytes);
|
||||
binaryWriter.WriteEncryptedString(versionList.ApplicableGameVersion, s_CachedHashBytes);
|
||||
binaryWriter.Write7BitEncodedInt32(versionList.InternalResourceVersion);
|
||||
UpdatableVersionList.Asset[] assets = versionList.GetAssets();
|
||||
binaryWriter.Write7BitEncodedInt32(assets.Length);
|
||||
foreach (UpdatableVersionList.Asset asset in assets)
|
||||
{
|
||||
binaryWriter.WriteEncryptedString(asset.Name, s_CachedHashBytes);
|
||||
int[] dependencyAssetIndexes = asset.GetDependencyAssetIndexes();
|
||||
binaryWriter.Write7BitEncodedInt32(dependencyAssetIndexes.Length);
|
||||
foreach (int dependencyAssetIndex in dependencyAssetIndexes)
|
||||
{
|
||||
binaryWriter.Write7BitEncodedInt32(dependencyAssetIndex);
|
||||
}
|
||||
}
|
||||
|
||||
UpdatableVersionList.Resource[] resources = versionList.GetResources();
|
||||
binaryWriter.Write7BitEncodedInt32(resources.Length);
|
||||
foreach (UpdatableVersionList.Resource resource in resources)
|
||||
{
|
||||
binaryWriter.WriteEncryptedString(resource.Name, s_CachedHashBytes);
|
||||
binaryWriter.WriteEncryptedString(resource.Variant, s_CachedHashBytes);
|
||||
binaryWriter.WriteEncryptedString(resource.Extension != DefaultExtension ? resource.Extension : null, s_CachedHashBytes);
|
||||
binaryWriter.Write(resource.LoadType);
|
||||
binaryWriter.Write7BitEncodedInt32(resource.Length);
|
||||
binaryWriter.Write(resource.HashCode);
|
||||
binaryWriter.Write7BitEncodedInt32(resource.CompressedLength);
|
||||
binaryWriter.Write(resource.CompressedHashCode);
|
||||
int[] assetIndexes = resource.GetAssetIndexes();
|
||||
binaryWriter.Write7BitEncodedInt32(assetIndexes.Length);
|
||||
foreach (int assetIndex in assetIndexes)
|
||||
{
|
||||
binaryWriter.Write7BitEncodedInt32(assetIndex);
|
||||
}
|
||||
}
|
||||
|
||||
UpdatableVersionList.FileSystem[] fileSystems = versionList.GetFileSystems();
|
||||
binaryWriter.Write7BitEncodedInt32(fileSystems.Length);
|
||||
foreach (UpdatableVersionList.FileSystem fileSystem in fileSystems)
|
||||
{
|
||||
binaryWriter.WriteEncryptedString(fileSystem.Name, s_CachedHashBytes);
|
||||
int[] resourceIndexes = fileSystem.GetResourceIndexes();
|
||||
binaryWriter.Write7BitEncodedInt32(resourceIndexes.Length);
|
||||
foreach (int resourceIndex in resourceIndexes)
|
||||
{
|
||||
binaryWriter.Write7BitEncodedInt32(resourceIndex);
|
||||
}
|
||||
}
|
||||
|
||||
UpdatableVersionList.ResourceGroup[] resourceGroups = versionList.GetResourceGroups();
|
||||
binaryWriter.Write7BitEncodedInt32(resourceGroups.Length);
|
||||
foreach (UpdatableVersionList.ResourceGroup resourceGroup in resourceGroups)
|
||||
{
|
||||
binaryWriter.WriteEncryptedString(resourceGroup.Name, s_CachedHashBytes);
|
||||
int[] resourceIndexes = resourceGroup.GetResourceIndexes();
|
||||
binaryWriter.Write7BitEncodedInt32(resourceIndexes.Length);
|
||||
foreach (int resourceIndex in resourceIndexes)
|
||||
{
|
||||
binaryWriter.Write7BitEncodedInt32(resourceIndex);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Array.Clear(s_CachedHashBytes, 0, CachedHashBytesLength);
|
||||
return true;
|
||||
}
|
||||
|
||||
#endif
|
||||
}
|
||||
}
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 9730081343813f34e8835804bf32290f
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
+70
@@ -0,0 +1,70 @@
|
||||
//------------------------------------------------------------
|
||||
// Game Framework
|
||||
// Copyright © 2013-2021 Jiang Yin. All rights reserved.
|
||||
// Homepage: https://gameframework.cn/
|
||||
// Feedback: mailto:ellan@gameframework.cn
|
||||
//------------------------------------------------------------
|
||||
|
||||
using System.IO;
|
||||
using System.Text;
|
||||
|
||||
namespace UnityGameFramework.Runtime
|
||||
{
|
||||
/// <summary>
|
||||
/// 内置版本资源列表序列化器。
|
||||
/// </summary>
|
||||
public static partial class BuiltinVersionListSerializer
|
||||
{
|
||||
/// <summary>
|
||||
/// 尝试从可更新模式版本资源列表(版本 0)获取指定键的值回调函数。
|
||||
/// </summary>
|
||||
/// <param name="stream">指定流。</param>
|
||||
/// <param name="key">指定键。</param>
|
||||
/// <param name="value">指定键的值。</param>
|
||||
/// <returns>从可更新模式版本资源列表(版本 0)获取指定键的值是否成功。</returns>
|
||||
public static bool UpdatableVersionListTryGetValueCallback_V0(Stream stream, string key, out object value)
|
||||
{
|
||||
value = null;
|
||||
if (key != "InternalResourceVersion")
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
using (BinaryReader binaryReader = new BinaryReader(stream, Encoding.UTF8))
|
||||
{
|
||||
binaryReader.BaseStream.Position += CachedHashBytesLength;
|
||||
byte stringLength = binaryReader.ReadByte();
|
||||
binaryReader.BaseStream.Position += stringLength;
|
||||
value = binaryReader.ReadInt32();
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 尝试从可更新模式版本资源列表(版本 1 或版本 2)获取指定键的值回调函数。
|
||||
/// </summary>
|
||||
/// <param name="stream">指定流。</param>
|
||||
/// <param name="key">指定键。</param>
|
||||
/// <param name="value">指定键的值。</param>
|
||||
/// <returns>从可更新模式版本资源列表(版本 1 或版本 2)获取指定键的值是否成功。</returns>
|
||||
public static bool UpdatableVersionListTryGetValueCallback_V1_V2(Stream stream, string key, out object value)
|
||||
{
|
||||
value = null;
|
||||
if (key != "InternalResourceVersion")
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
using (BinaryReader binaryReader = new BinaryReader(stream, Encoding.UTF8))
|
||||
{
|
||||
binaryReader.BaseStream.Position += CachedHashBytesLength;
|
||||
byte stringLength = binaryReader.ReadByte();
|
||||
binaryReader.BaseStream.Position += stringLength;
|
||||
value = binaryReader.Read7BitEncodedInt32();
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: c39515b9d8a0b0d4a9045edf9c8c1143
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,54 @@
|
||||
//------------------------------------------------------------
|
||||
// Game Framework
|
||||
// Copyright © 2013-2021 Jiang Yin. All rights reserved.
|
||||
// Homepage: https://gameframework.cn/
|
||||
// Feedback: mailto:ellan@gameframework.cn
|
||||
//------------------------------------------------------------
|
||||
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace UnityGameFramework.Runtime
|
||||
{
|
||||
/// <summary>
|
||||
/// 内置版本资源列表序列化器。
|
||||
/// </summary>
|
||||
public static partial class BuiltinVersionListSerializer
|
||||
{
|
||||
private const string DefaultExtension = "dat";
|
||||
private const int CachedHashBytesLength = 4;
|
||||
private static readonly byte[] s_CachedHashBytes = new byte[CachedHashBytesLength];
|
||||
|
||||
private static int AssetNameToDependencyAssetNamesComparer(KeyValuePair<string, string[]> a, KeyValuePair<string, string[]> b)
|
||||
{
|
||||
return a.Key.CompareTo(b.Key);
|
||||
}
|
||||
|
||||
private static int GetAssetNameIndex(List<KeyValuePair<string, string[]>> assetNameToDependencyAssetNames, string assetName)
|
||||
{
|
||||
return GetAssetNameIndexWithBinarySearch(assetNameToDependencyAssetNames, assetName, 0, assetNameToDependencyAssetNames.Count - 1);
|
||||
}
|
||||
|
||||
private static int GetAssetNameIndexWithBinarySearch(List<KeyValuePair<string, string[]>> assetNameToDependencyAssetNames, string assetName, int leftIndex, int rightIndex)
|
||||
{
|
||||
if (leftIndex > rightIndex)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
int middleIndex = (leftIndex + rightIndex) / 2;
|
||||
if (assetNameToDependencyAssetNames[middleIndex].Key == assetName)
|
||||
{
|
||||
return middleIndex;
|
||||
}
|
||||
|
||||
if (assetNameToDependencyAssetNames[middleIndex].Key.CompareTo(assetName) > 0)
|
||||
{
|
||||
return GetAssetNameIndexWithBinarySearch(assetNameToDependencyAssetNames, assetName, leftIndex, middleIndex - 1);
|
||||
}
|
||||
else
|
||||
{
|
||||
return GetAssetNameIndexWithBinarySearch(assetNameToDependencyAssetNames, assetName, middleIndex + 1, rightIndex);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: ca9f81a8ced0aa748b1a7a514ccf9948
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,595 @@
|
||||
//------------------------------------------------------------
|
||||
// Game Framework
|
||||
// Copyright © 2013-2021 Jiang Yin. All rights reserved.
|
||||
// Homepage: https://gameframework.cn/
|
||||
// Feedback: mailto:ellan@gameframework.cn
|
||||
//------------------------------------------------------------
|
||||
|
||||
using GameFramework;
|
||||
using GameFramework.FileSystem;
|
||||
using GameFramework.Resource;
|
||||
using System;
|
||||
using UnityEngine;
|
||||
#if UNITY_5_4_OR_NEWER
|
||||
using UnityEngine.Networking;
|
||||
#endif
|
||||
using UnityEngine.SceneManagement;
|
||||
using Utility = GameFramework.Utility;
|
||||
|
||||
namespace UnityGameFramework.Runtime
|
||||
{
|
||||
/// <summary>
|
||||
/// 默认加载资源代理辅助器。
|
||||
/// </summary>
|
||||
public class DefaultLoadResourceAgentHelper : LoadResourceAgentHelperBase, IDisposable
|
||||
{
|
||||
private string m_FileFullPath = null;
|
||||
private string m_FileName = null;
|
||||
private string m_BytesFullPath = null;
|
||||
private string m_AssetName = null;
|
||||
private float m_LastProgress = 0f;
|
||||
private bool m_Disposed = false;
|
||||
#if UNITY_5_4_OR_NEWER
|
||||
private UnityWebRequest m_UnityWebRequest = null;
|
||||
#else
|
||||
private WWW m_WWW = null;
|
||||
#endif
|
||||
private AssetBundleCreateRequest m_FileAssetBundleCreateRequest = null;
|
||||
private AssetBundleCreateRequest m_BytesAssetBundleCreateRequest = null;
|
||||
private AssetBundleRequest m_AssetBundleRequest = null;
|
||||
private AsyncOperation m_AsyncOperation = null;
|
||||
|
||||
private EventHandler<LoadResourceAgentHelperUpdateEventArgs> m_LoadResourceAgentHelperUpdateEventHandler = null;
|
||||
private EventHandler<LoadResourceAgentHelperReadFileCompleteEventArgs> m_LoadResourceAgentHelperReadFileCompleteEventHandler = null;
|
||||
private EventHandler<LoadResourceAgentHelperReadBytesCompleteEventArgs> m_LoadResourceAgentHelperReadBytesCompleteEventHandler = null;
|
||||
private EventHandler<LoadResourceAgentHelperParseBytesCompleteEventArgs> m_LoadResourceAgentHelperParseBytesCompleteEventHandler = null;
|
||||
private EventHandler<LoadResourceAgentHelperLoadCompleteEventArgs> m_LoadResourceAgentHelperLoadCompleteEventHandler = null;
|
||||
private EventHandler<LoadResourceAgentHelperErrorEventArgs> m_LoadResourceAgentHelperErrorEventHandler = null;
|
||||
|
||||
/// <summary>
|
||||
/// 加载资源代理辅助器异步加载资源更新事件。
|
||||
/// </summary>
|
||||
public override event EventHandler<LoadResourceAgentHelperUpdateEventArgs> LoadResourceAgentHelperUpdate
|
||||
{
|
||||
add
|
||||
{
|
||||
m_LoadResourceAgentHelperUpdateEventHandler += value;
|
||||
}
|
||||
remove
|
||||
{
|
||||
m_LoadResourceAgentHelperUpdateEventHandler -= value;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 加载资源代理辅助器异步读取资源文件完成事件。
|
||||
/// </summary>
|
||||
public override event EventHandler<LoadResourceAgentHelperReadFileCompleteEventArgs> LoadResourceAgentHelperReadFileComplete
|
||||
{
|
||||
add
|
||||
{
|
||||
m_LoadResourceAgentHelperReadFileCompleteEventHandler += value;
|
||||
}
|
||||
remove
|
||||
{
|
||||
m_LoadResourceAgentHelperReadFileCompleteEventHandler -= value;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 加载资源代理辅助器异步读取资源二进制流完成事件。
|
||||
/// </summary>
|
||||
public override event EventHandler<LoadResourceAgentHelperReadBytesCompleteEventArgs> LoadResourceAgentHelperReadBytesComplete
|
||||
{
|
||||
add
|
||||
{
|
||||
m_LoadResourceAgentHelperReadBytesCompleteEventHandler += value;
|
||||
}
|
||||
remove
|
||||
{
|
||||
m_LoadResourceAgentHelperReadBytesCompleteEventHandler -= value;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 加载资源代理辅助器异步将资源二进制流转换为加载对象完成事件。
|
||||
/// </summary>
|
||||
public override event EventHandler<LoadResourceAgentHelperParseBytesCompleteEventArgs> LoadResourceAgentHelperParseBytesComplete
|
||||
{
|
||||
add
|
||||
{
|
||||
m_LoadResourceAgentHelperParseBytesCompleteEventHandler += value;
|
||||
}
|
||||
remove
|
||||
{
|
||||
m_LoadResourceAgentHelperParseBytesCompleteEventHandler -= value;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 加载资源代理辅助器异步加载资源完成事件。
|
||||
/// </summary>
|
||||
public override event EventHandler<LoadResourceAgentHelperLoadCompleteEventArgs> LoadResourceAgentHelperLoadComplete
|
||||
{
|
||||
add
|
||||
{
|
||||
m_LoadResourceAgentHelperLoadCompleteEventHandler += value;
|
||||
}
|
||||
remove
|
||||
{
|
||||
m_LoadResourceAgentHelperLoadCompleteEventHandler -= value;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 加载资源代理辅助器错误事件。
|
||||
/// </summary>
|
||||
public override event EventHandler<LoadResourceAgentHelperErrorEventArgs> LoadResourceAgentHelperError
|
||||
{
|
||||
add
|
||||
{
|
||||
m_LoadResourceAgentHelperErrorEventHandler += value;
|
||||
}
|
||||
remove
|
||||
{
|
||||
m_LoadResourceAgentHelperErrorEventHandler -= value;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 通过加载资源代理辅助器开始异步读取资源文件。
|
||||
/// </summary>
|
||||
/// <param name="fullPath">要加载资源的完整路径名。</param>
|
||||
public override void ReadFile(string fullPath)
|
||||
{
|
||||
if (m_LoadResourceAgentHelperReadFileCompleteEventHandler == null || m_LoadResourceAgentHelperUpdateEventHandler == null || m_LoadResourceAgentHelperErrorEventHandler == null)
|
||||
{
|
||||
Log.Fatal("Load resource agent helper handler is invalid.");
|
||||
return;
|
||||
}
|
||||
|
||||
m_FileFullPath = fullPath;
|
||||
m_FileAssetBundleCreateRequest = AssetBundle.LoadFromFileAsync(fullPath);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 通过加载资源代理辅助器开始异步读取资源文件。
|
||||
/// </summary>
|
||||
/// <param name="fileSystem">要加载资源的文件系统。</param>
|
||||
/// <param name="name">要加载资源的名称。</param>
|
||||
public override void ReadFile(IFileSystem fileSystem, string name)
|
||||
{
|
||||
#if UNITY_5_3_5 || UNITY_5_3_6 || UNITY_5_3_7 || UNITY_5_3_8 || UNITY_5_4_OR_NEWER
|
||||
if (m_LoadResourceAgentHelperReadFileCompleteEventHandler == null || m_LoadResourceAgentHelperUpdateEventHandler == null || m_LoadResourceAgentHelperErrorEventHandler == null)
|
||||
{
|
||||
Log.Fatal("Load resource agent helper handler is invalid.");
|
||||
return;
|
||||
}
|
||||
|
||||
FileInfo fileInfo = fileSystem.GetFileInfo(name);
|
||||
m_FileFullPath = fileSystem.FullPath;
|
||||
m_FileName = name;
|
||||
m_FileAssetBundleCreateRequest = AssetBundle.LoadFromFileAsync(fileSystem.FullPath, 0u, (ulong)fileInfo.Offset);
|
||||
#else
|
||||
Log.Fatal("Load from file async with offset is not supported, use Unity 5.3.5f1 or above.");
|
||||
#endif
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 通过加载资源代理辅助器开始异步读取资源二进制流。
|
||||
/// </summary>
|
||||
/// <param name="fullPath">要加载资源的完整路径名。</param>
|
||||
public override void ReadBytes(string fullPath)
|
||||
{
|
||||
if (m_LoadResourceAgentHelperReadBytesCompleteEventHandler == null || m_LoadResourceAgentHelperUpdateEventHandler == null || m_LoadResourceAgentHelperErrorEventHandler == null)
|
||||
{
|
||||
Log.Fatal("Load resource agent helper handler is invalid.");
|
||||
return;
|
||||
}
|
||||
|
||||
m_BytesFullPath = fullPath;
|
||||
#if UNITY_5_4_OR_NEWER
|
||||
m_UnityWebRequest = UnityWebRequest.Get(Utility.Path.GetRemotePath(fullPath));
|
||||
#if UNITY_2017_2_OR_NEWER
|
||||
m_UnityWebRequest.SendWebRequest();
|
||||
#else
|
||||
m_UnityWebRequest.Send();
|
||||
#endif
|
||||
#else
|
||||
m_WWW = new WWW(Utility.Path.GetRemotePath(fullPath));
|
||||
#endif
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 通过加载资源代理辅助器开始异步读取资源二进制流。
|
||||
/// </summary>
|
||||
/// <param name="fileSystem">要加载资源的文件系统。</param>
|
||||
/// <param name="name">要加载资源的名称。</param>
|
||||
public override void ReadBytes(IFileSystem fileSystem, string name)
|
||||
{
|
||||
if (m_LoadResourceAgentHelperReadBytesCompleteEventHandler == null || m_LoadResourceAgentHelperUpdateEventHandler == null || m_LoadResourceAgentHelperErrorEventHandler == null)
|
||||
{
|
||||
Log.Fatal("Load resource agent helper handler is invalid.");
|
||||
return;
|
||||
}
|
||||
|
||||
byte[] bytes = fileSystem.ReadFile(name);
|
||||
LoadResourceAgentHelperReadBytesCompleteEventArgs loadResourceAgentHelperReadBytesCompleteEventArgs = LoadResourceAgentHelperReadBytesCompleteEventArgs.Create(bytes);
|
||||
m_LoadResourceAgentHelperReadBytesCompleteEventHandler(this, loadResourceAgentHelperReadBytesCompleteEventArgs);
|
||||
ReferencePool.Release(loadResourceAgentHelperReadBytesCompleteEventArgs);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 通过加载资源代理辅助器开始异步将资源二进制流转换为加载对象。
|
||||
/// </summary>
|
||||
/// <param name="bytes">要加载资源的二进制流。</param>
|
||||
public override void ParseBytes(byte[] bytes)
|
||||
{
|
||||
if (m_LoadResourceAgentHelperParseBytesCompleteEventHandler == null || m_LoadResourceAgentHelperUpdateEventHandler == null || m_LoadResourceAgentHelperErrorEventHandler == null)
|
||||
{
|
||||
Log.Fatal("Load resource agent helper handler is invalid.");
|
||||
return;
|
||||
}
|
||||
|
||||
m_BytesAssetBundleCreateRequest = AssetBundle.LoadFromMemoryAsync(bytes);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 通过加载资源代理辅助器开始异步加载资源。
|
||||
/// </summary>
|
||||
/// <param name="resource">资源。</param>
|
||||
/// <param name="assetName">要加载的资源名称。</param>
|
||||
/// <param name="assetType">要加载资源的类型。</param>
|
||||
/// <param name="isScene">要加载的资源是否是场景。</param>
|
||||
public override void LoadAsset(object resource, string assetName, Type assetType, bool isScene)
|
||||
{
|
||||
if (m_LoadResourceAgentHelperLoadCompleteEventHandler == null || m_LoadResourceAgentHelperUpdateEventHandler == null || m_LoadResourceAgentHelperErrorEventHandler == null)
|
||||
{
|
||||
Log.Fatal("Load resource agent helper handler is invalid.");
|
||||
return;
|
||||
}
|
||||
|
||||
AssetBundle assetBundle = resource as AssetBundle;
|
||||
if (assetBundle == null)
|
||||
{
|
||||
LoadResourceAgentHelperErrorEventArgs loadResourceAgentHelperErrorEventArgs = LoadResourceAgentHelperErrorEventArgs.Create(LoadResourceStatus.TypeError, "Can not load asset bundle from loaded resource which is not an asset bundle.");
|
||||
m_LoadResourceAgentHelperErrorEventHandler(this, loadResourceAgentHelperErrorEventArgs);
|
||||
ReferencePool.Release(loadResourceAgentHelperErrorEventArgs);
|
||||
return;
|
||||
}
|
||||
|
||||
if (string.IsNullOrEmpty(assetName))
|
||||
{
|
||||
LoadResourceAgentHelperErrorEventArgs loadResourceAgentHelperErrorEventArgs = LoadResourceAgentHelperErrorEventArgs.Create(LoadResourceStatus.AssetError, "Can not load asset from asset bundle which child name is invalid.");
|
||||
m_LoadResourceAgentHelperErrorEventHandler(this, loadResourceAgentHelperErrorEventArgs);
|
||||
ReferencePool.Release(loadResourceAgentHelperErrorEventArgs);
|
||||
return;
|
||||
}
|
||||
|
||||
m_AssetName = assetName;
|
||||
if (isScene)
|
||||
{
|
||||
int sceneNamePositionStart = assetName.LastIndexOf('/');
|
||||
int sceneNamePositionEnd = assetName.LastIndexOf('.');
|
||||
if (sceneNamePositionStart <= 0 || sceneNamePositionEnd <= 0 || sceneNamePositionStart > sceneNamePositionEnd)
|
||||
{
|
||||
LoadResourceAgentHelperErrorEventArgs loadResourceAgentHelperErrorEventArgs = LoadResourceAgentHelperErrorEventArgs.Create(LoadResourceStatus.AssetError, Utility.Text.Format("Scene name '{0}' is invalid.", assetName));
|
||||
m_LoadResourceAgentHelperErrorEventHandler(this, loadResourceAgentHelperErrorEventArgs);
|
||||
ReferencePool.Release(loadResourceAgentHelperErrorEventArgs);
|
||||
return;
|
||||
}
|
||||
|
||||
string sceneName = assetName.Substring(sceneNamePositionStart + 1, sceneNamePositionEnd - sceneNamePositionStart - 1);
|
||||
m_AsyncOperation = SceneManager.LoadSceneAsync(sceneName, LoadSceneMode.Additive);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (assetType != null)
|
||||
{
|
||||
m_AssetBundleRequest = assetBundle.LoadAssetAsync(assetName, assetType);
|
||||
}
|
||||
else
|
||||
{
|
||||
m_AssetBundleRequest = assetBundle.LoadAssetAsync(assetName);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 重置加载资源代理辅助器。
|
||||
/// </summary>
|
||||
public override void Reset()
|
||||
{
|
||||
m_FileFullPath = null;
|
||||
m_FileName = null;
|
||||
m_BytesFullPath = null;
|
||||
m_AssetName = null;
|
||||
m_LastProgress = 0f;
|
||||
|
||||
#if UNITY_5_4_OR_NEWER
|
||||
if (m_UnityWebRequest != null)
|
||||
{
|
||||
m_UnityWebRequest.Dispose();
|
||||
m_UnityWebRequest = null;
|
||||
}
|
||||
#else
|
||||
if (m_WWW != null)
|
||||
{
|
||||
m_WWW.Dispose();
|
||||
m_WWW = null;
|
||||
}
|
||||
#endif
|
||||
|
||||
m_FileAssetBundleCreateRequest = null;
|
||||
m_BytesAssetBundleCreateRequest = null;
|
||||
m_AssetBundleRequest = null;
|
||||
m_AsyncOperation = null;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 释放资源。
|
||||
/// </summary>
|
||||
public void Dispose()
|
||||
{
|
||||
Dispose(true);
|
||||
GC.SuppressFinalize(this);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 释放资源。
|
||||
/// </summary>
|
||||
/// <param name="disposing">释放资源标记。</param>
|
||||
protected virtual void Dispose(bool disposing)
|
||||
{
|
||||
if (m_Disposed)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (disposing)
|
||||
{
|
||||
#if UNITY_5_4_OR_NEWER
|
||||
if (m_UnityWebRequest != null)
|
||||
{
|
||||
m_UnityWebRequest.Dispose();
|
||||
m_UnityWebRequest = null;
|
||||
}
|
||||
#else
|
||||
if (m_WWW != null)
|
||||
{
|
||||
m_WWW.Dispose();
|
||||
m_WWW = null;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
m_Disposed = true;
|
||||
}
|
||||
|
||||
private void Update()
|
||||
{
|
||||
#if UNITY_5_4_OR_NEWER
|
||||
UpdateUnityWebRequest();
|
||||
#else
|
||||
UpdateWWW();
|
||||
#endif
|
||||
UpdateFileAssetBundleCreateRequest();
|
||||
UpdateBytesAssetBundleCreateRequest();
|
||||
UpdateAssetBundleRequest();
|
||||
UpdateAsyncOperation();
|
||||
}
|
||||
|
||||
#if UNITY_5_4_OR_NEWER
|
||||
private void UpdateUnityWebRequest()
|
||||
{
|
||||
if (m_UnityWebRequest != null)
|
||||
{
|
||||
if (m_UnityWebRequest.isDone)
|
||||
{
|
||||
if (string.IsNullOrEmpty(m_UnityWebRequest.error))
|
||||
{
|
||||
LoadResourceAgentHelperReadBytesCompleteEventArgs loadResourceAgentHelperReadBytesCompleteEventArgs = LoadResourceAgentHelperReadBytesCompleteEventArgs.Create(m_UnityWebRequest.downloadHandler.data);
|
||||
m_LoadResourceAgentHelperReadBytesCompleteEventHandler(this, loadResourceAgentHelperReadBytesCompleteEventArgs);
|
||||
ReferencePool.Release(loadResourceAgentHelperReadBytesCompleteEventArgs);
|
||||
m_UnityWebRequest.Dispose();
|
||||
m_UnityWebRequest = null;
|
||||
m_BytesFullPath = null;
|
||||
m_LastProgress = 0f;
|
||||
}
|
||||
else
|
||||
{
|
||||
bool isError = false;
|
||||
#if UNITY_2020_2_OR_NEWER
|
||||
isError = m_UnityWebRequest.result != UnityWebRequest.Result.Success;
|
||||
#elif UNITY_2017_1_OR_NEWER
|
||||
isError = m_UnityWebRequest.isNetworkError || m_UnityWebRequest.isHttpError;
|
||||
#else
|
||||
isError = m_UnityWebRequest.isError;
|
||||
#endif
|
||||
LoadResourceAgentHelperErrorEventArgs loadResourceAgentHelperErrorEventArgs = LoadResourceAgentHelperErrorEventArgs.Create(LoadResourceStatus.NotExist, Utility.Text.Format("Can not load asset bundle '{0}' with error message '{1}'.", m_BytesFullPath, isError ? m_UnityWebRequest.error : null));
|
||||
m_LoadResourceAgentHelperErrorEventHandler(this, loadResourceAgentHelperErrorEventArgs);
|
||||
ReferencePool.Release(loadResourceAgentHelperErrorEventArgs);
|
||||
}
|
||||
}
|
||||
else if (m_UnityWebRequest.downloadProgress != m_LastProgress)
|
||||
{
|
||||
m_LastProgress = m_UnityWebRequest.downloadProgress;
|
||||
LoadResourceAgentHelperUpdateEventArgs loadResourceAgentHelperUpdateEventArgs = LoadResourceAgentHelperUpdateEventArgs.Create(LoadResourceProgress.ReadResource, m_UnityWebRequest.downloadProgress);
|
||||
m_LoadResourceAgentHelperUpdateEventHandler(this, loadResourceAgentHelperUpdateEventArgs);
|
||||
ReferencePool.Release(loadResourceAgentHelperUpdateEventArgs);
|
||||
}
|
||||
}
|
||||
}
|
||||
#else
|
||||
private void UpdateWWW()
|
||||
{
|
||||
if (m_WWW != null)
|
||||
{
|
||||
if (m_WWW.isDone)
|
||||
{
|
||||
if (string.IsNullOrEmpty(m_WWW.error))
|
||||
{
|
||||
LoadResourceAgentHelperReadBytesCompleteEventArgs loadResourceAgentHelperReadBytesCompleteEventArgs = LoadResourceAgentHelperReadBytesCompleteEventArgs.Create(m_WWW.bytes);
|
||||
m_LoadResourceAgentHelperReadBytesCompleteEventHandler(this, loadResourceAgentHelperReadBytesCompleteEventArgs);
|
||||
ReferencePool.Release(loadResourceAgentHelperReadBytesCompleteEventArgs);
|
||||
m_WWW.Dispose();
|
||||
m_WWW = null;
|
||||
m_BytesFullPath = null;
|
||||
m_LastProgress = 0f;
|
||||
}
|
||||
else
|
||||
{
|
||||
LoadResourceAgentHelperErrorEventArgs loadResourceAgentHelperErrorEventArgs = LoadResourceAgentHelperErrorEventArgs.Create(LoadResourceStatus.NotExist, Utility.Text.Format("Can not load asset bundle '{0}' with error message '{1}'.", m_BytesFullPath, m_WWW.error));
|
||||
m_LoadResourceAgentHelperErrorEventHandler(this, loadResourceAgentHelperErrorEventArgs);
|
||||
ReferencePool.Release(loadResourceAgentHelperErrorEventArgs);
|
||||
}
|
||||
}
|
||||
else if (m_WWW.progress != m_LastProgress)
|
||||
{
|
||||
m_LastProgress = m_WWW.progress;
|
||||
LoadResourceAgentHelperUpdateEventArgs loadResourceAgentHelperUpdateEventArgs = LoadResourceAgentHelperUpdateEventArgs.Create(LoadResourceProgress.ReadResource, m_WWW.progress);
|
||||
m_LoadResourceAgentHelperUpdateEventHandler(this, loadResourceAgentHelperUpdateEventArgs);
|
||||
ReferencePool.Release(loadResourceAgentHelperUpdateEventArgs);
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
private void UpdateFileAssetBundleCreateRequest()
|
||||
{
|
||||
if (m_FileAssetBundleCreateRequest != null)
|
||||
{
|
||||
if (m_FileAssetBundleCreateRequest.isDone)
|
||||
{
|
||||
AssetBundle assetBundle = m_FileAssetBundleCreateRequest.assetBundle;
|
||||
if (assetBundle != null)
|
||||
{
|
||||
AssetBundleCreateRequest oldFileAssetBundleCreateRequest = m_FileAssetBundleCreateRequest;
|
||||
LoadResourceAgentHelperReadFileCompleteEventArgs loadResourceAgentHelperReadFileCompleteEventArgs = LoadResourceAgentHelperReadFileCompleteEventArgs.Create(assetBundle);
|
||||
m_LoadResourceAgentHelperReadFileCompleteEventHandler(this, loadResourceAgentHelperReadFileCompleteEventArgs);
|
||||
ReferencePool.Release(loadResourceAgentHelperReadFileCompleteEventArgs);
|
||||
if (m_FileAssetBundleCreateRequest == oldFileAssetBundleCreateRequest)
|
||||
{
|
||||
m_FileAssetBundleCreateRequest = null;
|
||||
m_LastProgress = 0f;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
LoadResourceAgentHelperErrorEventArgs loadResourceAgentHelperErrorEventArgs = LoadResourceAgentHelperErrorEventArgs.Create(LoadResourceStatus.NotExist, Utility.Text.Format("Can not load asset bundle from file '{0}' which is not a valid asset bundle.", m_FileName == null ? m_FileFullPath : Utility.Text.Format("{0} | {1}", m_FileFullPath, m_FileName)));
|
||||
m_LoadResourceAgentHelperErrorEventHandler(this, loadResourceAgentHelperErrorEventArgs);
|
||||
ReferencePool.Release(loadResourceAgentHelperErrorEventArgs);
|
||||
}
|
||||
}
|
||||
else if (m_FileAssetBundleCreateRequest.progress != m_LastProgress)
|
||||
{
|
||||
m_LastProgress = m_FileAssetBundleCreateRequest.progress;
|
||||
LoadResourceAgentHelperUpdateEventArgs loadResourceAgentHelperUpdateEventArgs = LoadResourceAgentHelperUpdateEventArgs.Create(LoadResourceProgress.LoadResource, m_FileAssetBundleCreateRequest.progress);
|
||||
m_LoadResourceAgentHelperUpdateEventHandler(this, loadResourceAgentHelperUpdateEventArgs);
|
||||
ReferencePool.Release(loadResourceAgentHelperUpdateEventArgs);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void UpdateBytesAssetBundleCreateRequest()
|
||||
{
|
||||
if (m_BytesAssetBundleCreateRequest != null)
|
||||
{
|
||||
if (m_BytesAssetBundleCreateRequest.isDone)
|
||||
{
|
||||
AssetBundle assetBundle = m_BytesAssetBundleCreateRequest.assetBundle;
|
||||
if (assetBundle != null)
|
||||
{
|
||||
AssetBundleCreateRequest oldBytesAssetBundleCreateRequest = m_BytesAssetBundleCreateRequest;
|
||||
LoadResourceAgentHelperParseBytesCompleteEventArgs loadResourceAgentHelperParseBytesCompleteEventArgs = LoadResourceAgentHelperParseBytesCompleteEventArgs.Create(assetBundle);
|
||||
m_LoadResourceAgentHelperParseBytesCompleteEventHandler(this, loadResourceAgentHelperParseBytesCompleteEventArgs);
|
||||
ReferencePool.Release(loadResourceAgentHelperParseBytesCompleteEventArgs);
|
||||
if (m_BytesAssetBundleCreateRequest == oldBytesAssetBundleCreateRequest)
|
||||
{
|
||||
m_BytesAssetBundleCreateRequest = null;
|
||||
m_LastProgress = 0f;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
LoadResourceAgentHelperErrorEventArgs loadResourceAgentHelperErrorEventArgs = LoadResourceAgentHelperErrorEventArgs.Create(LoadResourceStatus.NotExist, "Can not load asset bundle from memory which is not a valid asset bundle.");
|
||||
m_LoadResourceAgentHelperErrorEventHandler(this, loadResourceAgentHelperErrorEventArgs);
|
||||
ReferencePool.Release(loadResourceAgentHelperErrorEventArgs);
|
||||
}
|
||||
}
|
||||
else if (m_BytesAssetBundleCreateRequest.progress != m_LastProgress)
|
||||
{
|
||||
m_LastProgress = m_BytesAssetBundleCreateRequest.progress;
|
||||
LoadResourceAgentHelperUpdateEventArgs loadResourceAgentHelperUpdateEventArgs = LoadResourceAgentHelperUpdateEventArgs.Create(LoadResourceProgress.LoadResource, m_BytesAssetBundleCreateRequest.progress);
|
||||
m_LoadResourceAgentHelperUpdateEventHandler(this, loadResourceAgentHelperUpdateEventArgs);
|
||||
ReferencePool.Release(loadResourceAgentHelperUpdateEventArgs);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void UpdateAssetBundleRequest()
|
||||
{
|
||||
if (m_AssetBundleRequest != null)
|
||||
{
|
||||
if (m_AssetBundleRequest.isDone)
|
||||
{
|
||||
if (m_AssetBundleRequest.asset != null)
|
||||
{
|
||||
LoadResourceAgentHelperLoadCompleteEventArgs loadResourceAgentHelperLoadCompleteEventArgs = LoadResourceAgentHelperLoadCompleteEventArgs.Create(m_AssetBundleRequest.asset);
|
||||
m_LoadResourceAgentHelperLoadCompleteEventHandler(this, loadResourceAgentHelperLoadCompleteEventArgs);
|
||||
ReferencePool.Release(loadResourceAgentHelperLoadCompleteEventArgs);
|
||||
m_AssetName = null;
|
||||
m_LastProgress = 0f;
|
||||
m_AssetBundleRequest = null;
|
||||
}
|
||||
else
|
||||
{
|
||||
LoadResourceAgentHelperErrorEventArgs loadResourceAgentHelperErrorEventArgs = LoadResourceAgentHelperErrorEventArgs.Create(LoadResourceStatus.AssetError, Utility.Text.Format("Can not load asset '{0}' from asset bundle which is not exist.", m_AssetName));
|
||||
m_LoadResourceAgentHelperErrorEventHandler(this, loadResourceAgentHelperErrorEventArgs);
|
||||
ReferencePool.Release(loadResourceAgentHelperErrorEventArgs);
|
||||
}
|
||||
}
|
||||
else if (m_AssetBundleRequest.progress != m_LastProgress)
|
||||
{
|
||||
m_LastProgress = m_AssetBundleRequest.progress;
|
||||
LoadResourceAgentHelperUpdateEventArgs loadResourceAgentHelperUpdateEventArgs = LoadResourceAgentHelperUpdateEventArgs.Create(LoadResourceProgress.LoadAsset, m_AssetBundleRequest.progress);
|
||||
m_LoadResourceAgentHelperUpdateEventHandler(this, loadResourceAgentHelperUpdateEventArgs);
|
||||
ReferencePool.Release(loadResourceAgentHelperUpdateEventArgs);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void UpdateAsyncOperation()
|
||||
{
|
||||
if (m_AsyncOperation != null)
|
||||
{
|
||||
if (m_AsyncOperation.isDone)
|
||||
{
|
||||
if (m_AsyncOperation.allowSceneActivation)
|
||||
{
|
||||
SceneAsset sceneAsset = new SceneAsset();
|
||||
LoadResourceAgentHelperLoadCompleteEventArgs loadResourceAgentHelperLoadCompleteEventArgs = LoadResourceAgentHelperLoadCompleteEventArgs.Create(sceneAsset);
|
||||
m_LoadResourceAgentHelperLoadCompleteEventHandler(this, loadResourceAgentHelperLoadCompleteEventArgs);
|
||||
ReferencePool.Release(loadResourceAgentHelperLoadCompleteEventArgs);
|
||||
m_AssetName = null;
|
||||
m_LastProgress = 0f;
|
||||
m_AsyncOperation = null;
|
||||
}
|
||||
else
|
||||
{
|
||||
LoadResourceAgentHelperErrorEventArgs loadResourceAgentHelperErrorEventArgs = LoadResourceAgentHelperErrorEventArgs.Create(LoadResourceStatus.AssetError, Utility.Text.Format("Can not load scene asset '{0}' from asset bundle.", m_AssetName));
|
||||
m_LoadResourceAgentHelperErrorEventHandler(this, loadResourceAgentHelperErrorEventArgs);
|
||||
ReferencePool.Release(loadResourceAgentHelperErrorEventArgs);
|
||||
}
|
||||
}
|
||||
else if (m_AsyncOperation.progress != m_LastProgress)
|
||||
{
|
||||
m_LastProgress = m_AsyncOperation.progress;
|
||||
LoadResourceAgentHelperUpdateEventArgs loadResourceAgentHelperUpdateEventArgs = LoadResourceAgentHelperUpdateEventArgs.Create(LoadResourceProgress.LoadScene, m_AsyncOperation.progress);
|
||||
m_LoadResourceAgentHelperUpdateEventHandler(this, loadResourceAgentHelperUpdateEventArgs);
|
||||
ReferencePool.Release(loadResourceAgentHelperUpdateEventArgs);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 9288c544ad6d5a84d8e3610015bc5d61
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,185 @@
|
||||
//------------------------------------------------------------
|
||||
// Game Framework
|
||||
// Copyright © 2013-2021 Jiang Yin. All rights reserved.
|
||||
// Homepage: https://gameframework.cn/
|
||||
// Feedback: mailto:ellan@gameframework.cn
|
||||
//------------------------------------------------------------
|
||||
|
||||
using GameFramework.Resource;
|
||||
using System;
|
||||
using System.Collections;
|
||||
using UnityEngine;
|
||||
#if UNITY_5_4_OR_NEWER
|
||||
using UnityEngine.Networking;
|
||||
#endif
|
||||
using UnityEngine.SceneManagement;
|
||||
|
||||
namespace UnityGameFramework.Runtime
|
||||
{
|
||||
/// <summary>
|
||||
/// 默认资源辅助器。
|
||||
/// </summary>
|
||||
public class DefaultResourceHelper : ResourceHelperBase
|
||||
{
|
||||
/// <summary>
|
||||
/// 直接从指定文件路径加载数据流。
|
||||
/// </summary>
|
||||
/// <param name="fileUri">文件路径。</param>
|
||||
/// <param name="loadBytesCallbacks">加载数据流回调函数集。</param>
|
||||
/// <param name="userData">用户自定义数据。</param>
|
||||
public override void LoadBytes(string fileUri, LoadBytesCallbacks loadBytesCallbacks, object userData)
|
||||
{
|
||||
StartCoroutine(LoadBytesCo(fileUri, loadBytesCallbacks, userData));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 卸载场景。
|
||||
/// </summary>
|
||||
/// <param name="sceneAssetName">场景资源名称。</param>
|
||||
/// <param name="unloadSceneCallbacks">卸载场景回调函数集。</param>
|
||||
/// <param name="userData">用户自定义数据。</param>
|
||||
public override void UnloadScene(string sceneAssetName, UnloadSceneCallbacks unloadSceneCallbacks, object userData)
|
||||
{
|
||||
#if UNITY_5_5_OR_NEWER
|
||||
if (gameObject.activeInHierarchy)
|
||||
{
|
||||
StartCoroutine(UnloadSceneCo(sceneAssetName, unloadSceneCallbacks, userData));
|
||||
}
|
||||
else
|
||||
{
|
||||
SceneManager.UnloadSceneAsync(SceneComponent.GetSceneName(sceneAssetName));
|
||||
}
|
||||
#else
|
||||
if (SceneManager.UnloadScene(SceneComponent.GetSceneName(sceneAssetName)))
|
||||
{
|
||||
if (unloadSceneCallbacks.UnloadSceneSuccessCallback != null)
|
||||
{
|
||||
unloadSceneCallbacks.UnloadSceneSuccessCallback(sceneAssetName, userData);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (unloadSceneCallbacks.UnloadSceneFailureCallback != null)
|
||||
{
|
||||
unloadSceneCallbacks.UnloadSceneFailureCallback(sceneAssetName, userData);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 释放资源。
|
||||
/// </summary>
|
||||
/// <param name="objectToRelease">要释放的资源。</param>
|
||||
public override void Release(object objectToRelease)
|
||||
{
|
||||
AssetBundle assetBundle = objectToRelease as AssetBundle;
|
||||
if (assetBundle != null)
|
||||
{
|
||||
assetBundle.Unload(true);
|
||||
return;
|
||||
}
|
||||
|
||||
/* Unity 当前 Resources.UnloadAsset 在 iOS 设备上会导致一些诡异问题,先不用这部分
|
||||
SceneAsset sceneAsset = objectToRelease as SceneAsset;
|
||||
if (sceneAsset != null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
Object unityObject = objectToRelease as Object;
|
||||
if (unityObject == null)
|
||||
{
|
||||
Log.Warning("Asset is invalid.");
|
||||
return;
|
||||
}
|
||||
|
||||
if (unityObject is GameObject || unityObject is MonoBehaviour)
|
||||
{
|
||||
// UnloadAsset may only be used on individual assets and can not be used on GameObject's / Components or AssetBundles.
|
||||
return;
|
||||
}
|
||||
|
||||
Resources.UnloadAsset(unityObject);
|
||||
*/
|
||||
}
|
||||
|
||||
private void Start()
|
||||
{
|
||||
}
|
||||
|
||||
private IEnumerator LoadBytesCo(string fileUri, LoadBytesCallbacks loadBytesCallbacks, object userData)
|
||||
{
|
||||
bool isError = false;
|
||||
byte[] bytes = null;
|
||||
string errorMessage = null;
|
||||
DateTime startTime = DateTime.UtcNow;
|
||||
|
||||
#if UNITY_5_4_OR_NEWER
|
||||
UnityWebRequest unityWebRequest = UnityWebRequest.Get(fileUri);
|
||||
#if UNITY_2017_2_OR_NEWER
|
||||
yield return unityWebRequest.SendWebRequest();
|
||||
#else
|
||||
yield return unityWebRequest.Send();
|
||||
#endif
|
||||
|
||||
#if UNITY_2020_2_OR_NEWER
|
||||
isError = unityWebRequest.result != UnityWebRequest.Result.Success;
|
||||
#elif UNITY_2017_1_OR_NEWER
|
||||
isError = unityWebRequest.isNetworkError || unityWebRequest.isHttpError;
|
||||
#else
|
||||
isError = unityWebRequest.isError;
|
||||
#endif
|
||||
bytes = unityWebRequest.downloadHandler.data;
|
||||
errorMessage = isError ? unityWebRequest.error : null;
|
||||
unityWebRequest.Dispose();
|
||||
#else
|
||||
WWW www = new WWW(fileUri);
|
||||
yield return www;
|
||||
|
||||
isError = !string.IsNullOrEmpty(www.error);
|
||||
bytes = www.bytes;
|
||||
errorMessage = www.error;
|
||||
www.Dispose();
|
||||
#endif
|
||||
|
||||
if (!isError)
|
||||
{
|
||||
float elapseSeconds = (float)(DateTime.UtcNow - startTime).TotalSeconds;
|
||||
loadBytesCallbacks.LoadBytesSuccessCallback(fileUri, bytes, elapseSeconds, userData);
|
||||
}
|
||||
else if (loadBytesCallbacks.LoadBytesFailureCallback != null)
|
||||
{
|
||||
loadBytesCallbacks.LoadBytesFailureCallback(fileUri, errorMessage, userData);
|
||||
}
|
||||
}
|
||||
|
||||
#if UNITY_5_5_OR_NEWER
|
||||
private IEnumerator UnloadSceneCo(string sceneAssetName, UnloadSceneCallbacks unloadSceneCallbacks, object userData)
|
||||
{
|
||||
AsyncOperation asyncOperation = SceneManager.UnloadSceneAsync(SceneComponent.GetSceneName(sceneAssetName));
|
||||
if (asyncOperation == null)
|
||||
{
|
||||
yield break;
|
||||
}
|
||||
|
||||
yield return asyncOperation;
|
||||
|
||||
if (asyncOperation.allowSceneActivation)
|
||||
{
|
||||
if (unloadSceneCallbacks.UnloadSceneSuccessCallback != null)
|
||||
{
|
||||
unloadSceneCallbacks.UnloadSceneSuccessCallback(sceneAssetName, userData);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (unloadSceneCallbacks.UnloadSceneFailureCallback != null)
|
||||
{
|
||||
unloadSceneCallbacks.UnloadSceneFailureCallback(sceneAssetName, userData);
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 720e532446c14964a8fe343f1196793f
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: c26ec20b78ec32048bfb6c0ff875d8cd
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,96 @@
|
||||
//------------------------------------------------------------
|
||||
// Game Framework
|
||||
// Copyright © 2013-2021 Jiang Yin. All rights reserved.
|
||||
// Homepage: https://gameframework.cn/
|
||||
// Feedback: mailto:ellan@gameframework.cn
|
||||
//------------------------------------------------------------
|
||||
|
||||
using GameFramework.FileSystem;
|
||||
using GameFramework.Resource;
|
||||
using System;
|
||||
using UnityEngine;
|
||||
|
||||
namespace UnityGameFramework.Runtime
|
||||
{
|
||||
/// <summary>
|
||||
/// 加载资源代理辅助器基类。
|
||||
/// </summary>
|
||||
public abstract class LoadResourceAgentHelperBase : MonoBehaviour, ILoadResourceAgentHelper
|
||||
{
|
||||
/// <summary>
|
||||
/// 加载资源代理辅助器异步加载资源更新事件。
|
||||
/// </summary>
|
||||
public abstract event EventHandler<LoadResourceAgentHelperUpdateEventArgs> LoadResourceAgentHelperUpdate;
|
||||
|
||||
/// <summary>
|
||||
/// 加载资源代理辅助器异步读取资源文件完成事件。
|
||||
/// </summary>
|
||||
public abstract event EventHandler<LoadResourceAgentHelperReadFileCompleteEventArgs> LoadResourceAgentHelperReadFileComplete;
|
||||
|
||||
/// <summary>
|
||||
/// 加载资源代理辅助器异步读取资源二进制流完成事件。
|
||||
/// </summary>
|
||||
public abstract event EventHandler<LoadResourceAgentHelperReadBytesCompleteEventArgs> LoadResourceAgentHelperReadBytesComplete;
|
||||
|
||||
/// <summary>
|
||||
/// 加载资源代理辅助器异步将资源二进制流转换为加载对象完成事件。
|
||||
/// </summary>
|
||||
public abstract event EventHandler<LoadResourceAgentHelperParseBytesCompleteEventArgs> LoadResourceAgentHelperParseBytesComplete;
|
||||
|
||||
/// <summary>
|
||||
/// 加载资源代理辅助器异步加载资源完成事件。
|
||||
/// </summary>
|
||||
public abstract event EventHandler<LoadResourceAgentHelperLoadCompleteEventArgs> LoadResourceAgentHelperLoadComplete;
|
||||
|
||||
/// <summary>
|
||||
/// 加载资源代理辅助器错误事件。
|
||||
/// </summary>
|
||||
public abstract event EventHandler<LoadResourceAgentHelperErrorEventArgs> LoadResourceAgentHelperError;
|
||||
|
||||
/// <summary>
|
||||
/// 通过加载资源代理辅助器开始异步读取资源文件。
|
||||
/// </summary>
|
||||
/// <param name="fullPath">要加载资源的完整路径名。</param>
|
||||
public abstract void ReadFile(string fullPath);
|
||||
|
||||
/// <summary>
|
||||
/// 通过加载资源代理辅助器开始异步读取资源文件。
|
||||
/// </summary>
|
||||
/// <param name="fileSystem">要加载资源的文件系统。</param>
|
||||
/// <param name="name">要加载资源的名称。</param>
|
||||
public abstract void ReadFile(IFileSystem fileSystem, string name);
|
||||
|
||||
/// <summary>
|
||||
/// 通过加载资源代理辅助器开始异步读取资源二进制流。
|
||||
/// </summary>
|
||||
/// <param name="fullPath">要加载资源的完整路径名。</param>
|
||||
public abstract void ReadBytes(string fullPath);
|
||||
|
||||
/// <summary>
|
||||
/// 通过加载资源代理辅助器开始异步读取资源二进制流。
|
||||
/// </summary>
|
||||
/// <param name="fileSystem">要加载资源的文件系统。</param>
|
||||
/// <param name="name">要加载资源的名称。</param>
|
||||
public abstract void ReadBytes(IFileSystem fileSystem, string name);
|
||||
|
||||
/// <summary>
|
||||
/// 通过加载资源代理辅助器开始异步将资源二进制流转换为加载对象。
|
||||
/// </summary>
|
||||
/// <param name="bytes">要加载资源的二进制流。</param>
|
||||
public abstract void ParseBytes(byte[] bytes);
|
||||
|
||||
/// <summary>
|
||||
/// 通过加载资源代理辅助器开始异步加载资源。
|
||||
/// </summary>
|
||||
/// <param name="resource">资源。</param>
|
||||
/// <param name="assetName">要加载的资源名称。</param>
|
||||
/// <param name="assetType">要加载资源的类型。</param>
|
||||
/// <param name="isScene">要加载的资源是否是场景。</param>
|
||||
public abstract void LoadAsset(object resource, string assetName, Type assetType, bool isScene);
|
||||
|
||||
/// <summary>
|
||||
/// 重置加载资源代理辅助器。
|
||||
/// </summary>
|
||||
public abstract void Reset();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 753d0ffbb600b8a4888c18a954ca0985
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,30 @@
|
||||
//------------------------------------------------------------
|
||||
// Game Framework
|
||||
// Copyright © 2013-2021 Jiang Yin. All rights reserved.
|
||||
// Homepage: https://gameframework.cn/
|
||||
// Feedback: mailto:ellan@gameframework.cn
|
||||
//------------------------------------------------------------
|
||||
|
||||
namespace UnityGameFramework.Runtime
|
||||
{
|
||||
/// <summary>
|
||||
/// 读写区路径类型。
|
||||
/// </summary>
|
||||
public enum ReadWritePathType : byte
|
||||
{
|
||||
/// <summary>
|
||||
/// 未指定。
|
||||
/// </summary>
|
||||
Unspecified = 0,
|
||||
|
||||
/// <summary>
|
||||
/// 临时缓存。
|
||||
/// </summary>
|
||||
TemporaryCache,
|
||||
|
||||
/// <summary>
|
||||
/// 持久化数据。
|
||||
/// </summary>
|
||||
PersistentData,
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 59125eb0ef72f9a4cbe2fd08f0876ed7
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,95 @@
|
||||
//------------------------------------------------------------
|
||||
// Game Framework
|
||||
// Copyright © 2013-2021 Jiang Yin. All rights reserved.
|
||||
// Homepage: https://gameframework.cn/
|
||||
// Feedback: mailto:ellan@gameframework.cn
|
||||
//------------------------------------------------------------
|
||||
|
||||
using GameFramework;
|
||||
using GameFramework.Event;
|
||||
|
||||
namespace UnityGameFramework.Runtime
|
||||
{
|
||||
/// <summary>
|
||||
/// 资源应用失败事件。
|
||||
/// </summary>
|
||||
public sealed class ResourceApplyFailureEventArgs : GameEventArgs
|
||||
{
|
||||
/// <summary>
|
||||
/// 资源应用失败事件编号。
|
||||
/// </summary>
|
||||
public static readonly int EventId = typeof(ResourceApplyFailureEventArgs).GetHashCode();
|
||||
|
||||
/// <summary>
|
||||
/// 初始化资源应用失败事件的新实例。
|
||||
/// </summary>
|
||||
public ResourceApplyFailureEventArgs()
|
||||
{
|
||||
Name = null;
|
||||
ResourcePackPath = null;
|
||||
ErrorMessage = null;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取资源应用失败事件编号。
|
||||
/// </summary>
|
||||
public override int Id
|
||||
{
|
||||
get
|
||||
{
|
||||
return EventId;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取资源名称。
|
||||
/// </summary>
|
||||
public string Name
|
||||
{
|
||||
get;
|
||||
private set;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取资源包路径。
|
||||
/// </summary>
|
||||
public string ResourcePackPath
|
||||
{
|
||||
get;
|
||||
private set;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取错误信息。
|
||||
/// </summary>
|
||||
public string ErrorMessage
|
||||
{
|
||||
get;
|
||||
private set;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 创建资源应用失败事件。
|
||||
/// </summary>
|
||||
/// <param name="e">内部事件。</param>
|
||||
/// <returns>创建的资源应用失败事件。</returns>
|
||||
public static ResourceApplyFailureEventArgs Create(GameFramework.Resource.ResourceApplyFailureEventArgs e)
|
||||
{
|
||||
ResourceApplyFailureEventArgs resourceApplyFailureEventArgs = ReferencePool.Acquire<ResourceApplyFailureEventArgs>();
|
||||
resourceApplyFailureEventArgs.Name = e.Name;
|
||||
resourceApplyFailureEventArgs.ResourcePackPath = e.ResourcePackPath;
|
||||
resourceApplyFailureEventArgs.ErrorMessage = e.ErrorMessage;
|
||||
return resourceApplyFailureEventArgs;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 清理资源应用失败事件。
|
||||
/// </summary>
|
||||
public override void Clear()
|
||||
{
|
||||
Name = null;
|
||||
ResourcePackPath = null;
|
||||
ErrorMessage = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 66fd3ef74ebb3c64a85b92714b6fca9f
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,95 @@
|
||||
//------------------------------------------------------------
|
||||
// Game Framework
|
||||
// Copyright © 2013-2021 Jiang Yin. All rights reserved.
|
||||
// Homepage: https://gameframework.cn/
|
||||
// Feedback: mailto:ellan@gameframework.cn
|
||||
//------------------------------------------------------------
|
||||
|
||||
using GameFramework;
|
||||
using GameFramework.Event;
|
||||
|
||||
namespace UnityGameFramework.Runtime
|
||||
{
|
||||
/// <summary>
|
||||
/// 资源应用开始事件。
|
||||
/// </summary>
|
||||
public sealed class ResourceApplyStartEventArgs : GameEventArgs
|
||||
{
|
||||
/// <summary>
|
||||
/// 资源应用开始事件编号。
|
||||
/// </summary>
|
||||
public static readonly int EventId = typeof(ResourceApplyStartEventArgs).GetHashCode();
|
||||
|
||||
/// <summary>
|
||||
/// 初始化资源应用开始事件的新实例。
|
||||
/// </summary>
|
||||
public ResourceApplyStartEventArgs()
|
||||
{
|
||||
ResourcePackPath = null;
|
||||
Count = 0;
|
||||
TotalLength = 0L;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取资源应用开始事件编号。
|
||||
/// </summary>
|
||||
public override int Id
|
||||
{
|
||||
get
|
||||
{
|
||||
return EventId;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取资源包路径。
|
||||
/// </summary>
|
||||
public string ResourcePackPath
|
||||
{
|
||||
get;
|
||||
private set;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取要应用资源的数量。
|
||||
/// </summary>
|
||||
public int Count
|
||||
{
|
||||
get;
|
||||
private set;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取要应用资源的总大小。
|
||||
/// </summary>
|
||||
public long TotalLength
|
||||
{
|
||||
get;
|
||||
private set;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 创建资源应用开始事件。
|
||||
/// </summary>
|
||||
/// <param name="e">内部事件。</param>
|
||||
/// <returns>创建的资源应用开始事件。</returns>
|
||||
public static ResourceApplyStartEventArgs Create(GameFramework.Resource.ResourceApplyStartEventArgs e)
|
||||
{
|
||||
ResourceApplyStartEventArgs resourceApplyStartEventArgs = ReferencePool.Acquire<ResourceApplyStartEventArgs>();
|
||||
resourceApplyStartEventArgs.ResourcePackPath = e.ResourcePackPath;
|
||||
resourceApplyStartEventArgs.Count = e.Count;
|
||||
resourceApplyStartEventArgs.TotalLength = e.TotalLength;
|
||||
return resourceApplyStartEventArgs;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 清理资源应用开始事件。
|
||||
/// </summary>
|
||||
public override void Clear()
|
||||
{
|
||||
ResourcePackPath = null;
|
||||
Count = 0;
|
||||
TotalLength = 0L;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: a2b8dac8903914b4b90a288cb8ad3d06
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,119 @@
|
||||
//------------------------------------------------------------
|
||||
// Game Framework
|
||||
// Copyright © 2013-2021 Jiang Yin. All rights reserved.
|
||||
// Homepage: https://gameframework.cn/
|
||||
// Feedback: mailto:ellan@gameframework.cn
|
||||
//------------------------------------------------------------
|
||||
|
||||
using GameFramework;
|
||||
using GameFramework.Event;
|
||||
|
||||
namespace UnityGameFramework.Runtime
|
||||
{
|
||||
/// <summary>
|
||||
/// 资源应用成功事件。
|
||||
/// </summary>
|
||||
public sealed class ResourceApplySuccessEventArgs : GameEventArgs
|
||||
{
|
||||
/// <summary>
|
||||
/// 资源应用成功事件编号。
|
||||
/// </summary>
|
||||
public static readonly int EventId = typeof(ResourceApplySuccessEventArgs).GetHashCode();
|
||||
|
||||
/// <summary>
|
||||
/// 初始化资源应用成功事件的新实例。
|
||||
/// </summary>
|
||||
public ResourceApplySuccessEventArgs()
|
||||
{
|
||||
Name = null;
|
||||
ApplyPath = null;
|
||||
ResourcePackPath = null;
|
||||
Length = 0;
|
||||
CompressedLength = 0;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取资源应用成功事件编号。
|
||||
/// </summary>
|
||||
public override int Id
|
||||
{
|
||||
get
|
||||
{
|
||||
return EventId;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取资源名称。
|
||||
/// </summary>
|
||||
public string Name
|
||||
{
|
||||
get;
|
||||
private set;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取资源应用后存放路径。
|
||||
/// </summary>
|
||||
public string ApplyPath
|
||||
{
|
||||
get;
|
||||
private set;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取资源包路径。
|
||||
/// </summary>
|
||||
public string ResourcePackPath
|
||||
{
|
||||
get;
|
||||
private set;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取资源大小。
|
||||
/// </summary>
|
||||
public int Length
|
||||
{
|
||||
get;
|
||||
private set;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取压缩后大小。
|
||||
/// </summary>
|
||||
public int CompressedLength
|
||||
{
|
||||
get;
|
||||
private set;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 创建资源应用成功事件。
|
||||
/// </summary>
|
||||
/// <param name="e">内部事件。</param>
|
||||
/// <returns>创建的资源应用成功事件。</returns>
|
||||
public static ResourceApplySuccessEventArgs Create(GameFramework.Resource.ResourceApplySuccessEventArgs e)
|
||||
{
|
||||
ResourceApplySuccessEventArgs resourceApplySuccessEventArgs = ReferencePool.Acquire<ResourceApplySuccessEventArgs>();
|
||||
resourceApplySuccessEventArgs.Name = e.Name;
|
||||
resourceApplySuccessEventArgs.ApplyPath = e.ApplyPath;
|
||||
resourceApplySuccessEventArgs.ResourcePackPath = e.ResourcePackPath;
|
||||
resourceApplySuccessEventArgs.Length = e.Length;
|
||||
resourceApplySuccessEventArgs.CompressedLength = e.CompressedLength;
|
||||
return resourceApplySuccessEventArgs;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 清理资源应用成功事件。
|
||||
/// </summary>
|
||||
public override void Clear()
|
||||
{
|
||||
Name = null;
|
||||
ApplyPath = null;
|
||||
ResourcePackPath = null;
|
||||
Length = 0;
|
||||
CompressedLength = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: b5a9d46578a27a441a20e8578c940b42
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 7eff66e40586ec14d8a301d416f17f1e
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,40 @@
|
||||
//------------------------------------------------------------
|
||||
// Game Framework
|
||||
// Copyright © 2013-2021 Jiang Yin. All rights reserved.
|
||||
// Homepage: https://gameframework.cn/
|
||||
// Feedback: mailto:ellan@gameframework.cn
|
||||
//------------------------------------------------------------
|
||||
|
||||
using GameFramework.Resource;
|
||||
using UnityEngine;
|
||||
|
||||
namespace UnityGameFramework.Runtime
|
||||
{
|
||||
/// <summary>
|
||||
/// 资源辅助器基类。
|
||||
/// </summary>
|
||||
public abstract class ResourceHelperBase : MonoBehaviour, IResourceHelper
|
||||
{
|
||||
/// <summary>
|
||||
/// 直接从指定文件路径加载数据流。
|
||||
/// </summary>
|
||||
/// <param name="fileUri">文件路径。</param>
|
||||
/// <param name="loadBytesCallbacks">加载数据流回调函数集。</param>
|
||||
/// <param name="userData">用户自定义数据。</param>
|
||||
public abstract void LoadBytes(string fileUri, LoadBytesCallbacks loadBytesCallbacks, object userData);
|
||||
|
||||
/// <summary>
|
||||
/// 卸载场景。
|
||||
/// </summary>
|
||||
/// <param name="sceneAssetName">场景资源名称。</param>
|
||||
/// <param name="unloadSceneCallbacks">卸载场景回调函数集。</param>
|
||||
/// <param name="userData">用户自定义数据。</param>
|
||||
public abstract void UnloadScene(string sceneAssetName, UnloadSceneCallbacks unloadSceneCallbacks, object userData);
|
||||
|
||||
/// <summary>
|
||||
/// 释放资源。
|
||||
/// </summary>
|
||||
/// <param name="objectToRelease">要释放的资源。</param>
|
||||
public abstract void Release(object objectToRelease);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 231b6034e6f70794886826c9ba18dc2d
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,58 @@
|
||||
//------------------------------------------------------------
|
||||
// Game Framework
|
||||
// Copyright © 2013-2021 Jiang Yin. All rights reserved.
|
||||
// Homepage: https://gameframework.cn/
|
||||
// Feedback: mailto:ellan@gameframework.cn
|
||||
//------------------------------------------------------------
|
||||
|
||||
using GameFramework;
|
||||
using GameFramework.Event;
|
||||
|
||||
namespace UnityGameFramework.Runtime
|
||||
{
|
||||
/// <summary>
|
||||
/// 资源更新全部完成事件。
|
||||
/// </summary>
|
||||
public sealed class ResourceUpdateAllCompleteEventArgs : GameEventArgs
|
||||
{
|
||||
/// <summary>
|
||||
/// 资源更新全部完成事件编号。
|
||||
/// </summary>
|
||||
public static readonly int EventId = typeof(ResourceUpdateAllCompleteEventArgs).GetHashCode();
|
||||
|
||||
/// <summary>
|
||||
/// 初始化资源更新全部完成事件的新实例。
|
||||
/// </summary>
|
||||
public ResourceUpdateAllCompleteEventArgs()
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取资源更新全部完成事件编号。
|
||||
/// </summary>
|
||||
public override int Id
|
||||
{
|
||||
get
|
||||
{
|
||||
return EventId;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 创建资源更新全部完成事件。
|
||||
/// </summary>
|
||||
/// <param name="e">内部事件。</param>
|
||||
/// <returns>创建的资源更新全部完成事件。</returns>
|
||||
public static ResourceUpdateAllCompleteEventArgs Create(GameFramework.Resource.ResourceUpdateAllCompleteEventArgs e)
|
||||
{
|
||||
return ReferencePool.Acquire<ResourceUpdateAllCompleteEventArgs>();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 清理资源更新全部完成事件。
|
||||
/// </summary>
|
||||
public override void Clear()
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 2170354b236b90446bdd75a841140b52
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,119 @@
|
||||
//------------------------------------------------------------
|
||||
// Game Framework
|
||||
// Copyright © 2013-2021 Jiang Yin. All rights reserved.
|
||||
// Homepage: https://gameframework.cn/
|
||||
// Feedback: mailto:ellan@gameframework.cn
|
||||
//------------------------------------------------------------
|
||||
|
||||
using GameFramework;
|
||||
using GameFramework.Event;
|
||||
|
||||
namespace UnityGameFramework.Runtime
|
||||
{
|
||||
/// <summary>
|
||||
/// 资源更新改变事件。
|
||||
/// </summary>
|
||||
public sealed class ResourceUpdateChangedEventArgs : GameEventArgs
|
||||
{
|
||||
/// <summary>
|
||||
/// 资源更新改变事件编号。
|
||||
/// </summary>
|
||||
public static readonly int EventId = typeof(ResourceUpdateChangedEventArgs).GetHashCode();
|
||||
|
||||
/// <summary>
|
||||
/// 初始化资源更新改变事件的新实例。
|
||||
/// </summary>
|
||||
public ResourceUpdateChangedEventArgs()
|
||||
{
|
||||
Name = null;
|
||||
DownloadPath = null;
|
||||
DownloadUri = null;
|
||||
CurrentLength = 0;
|
||||
CompressedLength = 0;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取资源更新改变事件编号。
|
||||
/// </summary>
|
||||
public override int Id
|
||||
{
|
||||
get
|
||||
{
|
||||
return EventId;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取资源名称。
|
||||
/// </summary>
|
||||
public string Name
|
||||
{
|
||||
get;
|
||||
private set;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取资源下载后存放路径。
|
||||
/// </summary>
|
||||
public string DownloadPath
|
||||
{
|
||||
get;
|
||||
private set;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取下载地址。
|
||||
/// </summary>
|
||||
public string DownloadUri
|
||||
{
|
||||
get;
|
||||
private set;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取当前下载大小。
|
||||
/// </summary>
|
||||
public int CurrentLength
|
||||
{
|
||||
get;
|
||||
private set;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取压缩后大小。
|
||||
/// </summary>
|
||||
public int CompressedLength
|
||||
{
|
||||
get;
|
||||
private set;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 创建资源更新改变事件。
|
||||
/// </summary>
|
||||
/// <param name="e">内部事件。</param>
|
||||
/// <returns>创建的资源更新改变事件。</returns>
|
||||
public static ResourceUpdateChangedEventArgs Create(GameFramework.Resource.ResourceUpdateChangedEventArgs e)
|
||||
{
|
||||
ResourceUpdateChangedEventArgs resourceUpdateChangedEventArgs = ReferencePool.Acquire<ResourceUpdateChangedEventArgs>();
|
||||
resourceUpdateChangedEventArgs.Name = e.Name;
|
||||
resourceUpdateChangedEventArgs.DownloadPath = e.DownloadPath;
|
||||
resourceUpdateChangedEventArgs.DownloadUri = e.DownloadUri;
|
||||
resourceUpdateChangedEventArgs.CurrentLength = e.CurrentLength;
|
||||
resourceUpdateChangedEventArgs.CompressedLength = e.CompressedLength;
|
||||
return resourceUpdateChangedEventArgs;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 清理资源更新改变事件。
|
||||
/// </summary>
|
||||
public override void Clear()
|
||||
{
|
||||
Name = null;
|
||||
DownloadPath = null;
|
||||
DownloadUri = null;
|
||||
CurrentLength = 0;
|
||||
CompressedLength = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 578263f614242464495370d64b664c7f
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,119 @@
|
||||
//------------------------------------------------------------
|
||||
// Game Framework
|
||||
// Copyright © 2013-2021 Jiang Yin. All rights reserved.
|
||||
// Homepage: https://gameframework.cn/
|
||||
// Feedback: mailto:ellan@gameframework.cn
|
||||
//------------------------------------------------------------
|
||||
|
||||
using GameFramework;
|
||||
using GameFramework.Event;
|
||||
|
||||
namespace UnityGameFramework.Runtime
|
||||
{
|
||||
/// <summary>
|
||||
/// 资源更新失败事件。
|
||||
/// </summary>
|
||||
public sealed class ResourceUpdateFailureEventArgs : GameEventArgs
|
||||
{
|
||||
/// <summary>
|
||||
/// 资源更新失败事件编号。
|
||||
/// </summary>
|
||||
public static readonly int EventId = typeof(ResourceUpdateFailureEventArgs).GetHashCode();
|
||||
|
||||
/// <summary>
|
||||
/// 初始化资源更新失败事件的新实例。
|
||||
/// </summary>
|
||||
public ResourceUpdateFailureEventArgs()
|
||||
{
|
||||
Name = null;
|
||||
DownloadUri = null;
|
||||
RetryCount = 0;
|
||||
TotalRetryCount = 0;
|
||||
ErrorMessage = null;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取资源更新失败事件编号。
|
||||
/// </summary>
|
||||
public override int Id
|
||||
{
|
||||
get
|
||||
{
|
||||
return EventId;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取资源名称。
|
||||
/// </summary>
|
||||
public string Name
|
||||
{
|
||||
get;
|
||||
private set;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取下载地址。
|
||||
/// </summary>
|
||||
public string DownloadUri
|
||||
{
|
||||
get;
|
||||
private set;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取已重试次数。
|
||||
/// </summary>
|
||||
public int RetryCount
|
||||
{
|
||||
get;
|
||||
private set;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取设定的重试次数。
|
||||
/// </summary>
|
||||
public int TotalRetryCount
|
||||
{
|
||||
get;
|
||||
private set;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取错误信息。
|
||||
/// </summary>
|
||||
public string ErrorMessage
|
||||
{
|
||||
get;
|
||||
private set;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 创建资源更新失败事件。
|
||||
/// </summary>
|
||||
/// <param name="e">内部事件。</param>
|
||||
/// <returns>创建的资源更新失败事件。</returns>
|
||||
public static ResourceUpdateFailureEventArgs Create(GameFramework.Resource.ResourceUpdateFailureEventArgs e)
|
||||
{
|
||||
ResourceUpdateFailureEventArgs resourceUpdateFailureEventArgs = ReferencePool.Acquire<ResourceUpdateFailureEventArgs>();
|
||||
resourceUpdateFailureEventArgs.Name = e.Name;
|
||||
resourceUpdateFailureEventArgs.DownloadUri = e.DownloadUri;
|
||||
resourceUpdateFailureEventArgs.RetryCount = e.RetryCount;
|
||||
resourceUpdateFailureEventArgs.TotalRetryCount = e.TotalRetryCount;
|
||||
resourceUpdateFailureEventArgs.ErrorMessage = e.ErrorMessage;
|
||||
return resourceUpdateFailureEventArgs;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 清理资源更新失败事件。
|
||||
/// </summary>
|
||||
public override void Clear()
|
||||
{
|
||||
Name = null;
|
||||
DownloadUri = null;
|
||||
RetryCount = 0;
|
||||
TotalRetryCount = 0;
|
||||
ErrorMessage = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 6425ae0a812a24b4a863461585a7c7ea
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,131 @@
|
||||
//------------------------------------------------------------
|
||||
// Game Framework
|
||||
// Copyright © 2013-2021 Jiang Yin. All rights reserved.
|
||||
// Homepage: https://gameframework.cn/
|
||||
// Feedback: mailto:ellan@gameframework.cn
|
||||
//------------------------------------------------------------
|
||||
|
||||
using GameFramework;
|
||||
using GameFramework.Event;
|
||||
|
||||
namespace UnityGameFramework.Runtime
|
||||
{
|
||||
/// <summary>
|
||||
/// 资源更新开始事件。
|
||||
/// </summary>
|
||||
public sealed class ResourceUpdateStartEventArgs : GameEventArgs
|
||||
{
|
||||
/// <summary>
|
||||
/// 资源更新开始事件编号。
|
||||
/// </summary>
|
||||
public static readonly int EventId = typeof(ResourceUpdateStartEventArgs).GetHashCode();
|
||||
|
||||
/// <summary>
|
||||
/// 初始化资源更新开始事件的新实例。
|
||||
/// </summary>
|
||||
public ResourceUpdateStartEventArgs()
|
||||
{
|
||||
Name = null;
|
||||
DownloadPath = null;
|
||||
DownloadUri = null;
|
||||
CurrentLength = 0;
|
||||
CompressedLength = 0;
|
||||
RetryCount = 0;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取资源更新开始事件编号。
|
||||
/// </summary>
|
||||
public override int Id
|
||||
{
|
||||
get
|
||||
{
|
||||
return EventId;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取资源名称。
|
||||
/// </summary>
|
||||
public string Name
|
||||
{
|
||||
get;
|
||||
private set;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取资源下载后存放路径。
|
||||
/// </summary>
|
||||
public string DownloadPath
|
||||
{
|
||||
get;
|
||||
private set;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取下载地址。
|
||||
/// </summary>
|
||||
public string DownloadUri
|
||||
{
|
||||
get;
|
||||
private set;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取当前下载大小。
|
||||
/// </summary>
|
||||
public int CurrentLength
|
||||
{
|
||||
get;
|
||||
private set;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取压缩后大小。
|
||||
/// </summary>
|
||||
public int CompressedLength
|
||||
{
|
||||
get;
|
||||
private set;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取已重试下载次数。
|
||||
/// </summary>
|
||||
public int RetryCount
|
||||
{
|
||||
get;
|
||||
private set;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 创建资源更新开始事件。
|
||||
/// </summary>
|
||||
/// <param name="e">内部事件。</param>
|
||||
/// <returns>创建的资源更新开始事件。</returns>
|
||||
public static ResourceUpdateStartEventArgs Create(GameFramework.Resource.ResourceUpdateStartEventArgs e)
|
||||
{
|
||||
ResourceUpdateStartEventArgs resourceUpdateStartEventArgs = ReferencePool.Acquire<ResourceUpdateStartEventArgs>();
|
||||
resourceUpdateStartEventArgs.Name = e.Name;
|
||||
resourceUpdateStartEventArgs.DownloadPath = e.DownloadPath;
|
||||
resourceUpdateStartEventArgs.DownloadUri = e.DownloadUri;
|
||||
resourceUpdateStartEventArgs.CurrentLength = e.CurrentLength;
|
||||
resourceUpdateStartEventArgs.CompressedLength = e.CompressedLength;
|
||||
resourceUpdateStartEventArgs.RetryCount = e.RetryCount;
|
||||
return resourceUpdateStartEventArgs;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 清理资源更新开始事件。
|
||||
/// </summary>
|
||||
public override void Clear()
|
||||
{
|
||||
Name = null;
|
||||
DownloadPath = null;
|
||||
DownloadUri = null;
|
||||
CurrentLength = 0;
|
||||
CompressedLength = 0;
|
||||
RetryCount = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: b52ac443f249b2549827406d63bcbc57
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,119 @@
|
||||
//------------------------------------------------------------
|
||||
// Game Framework
|
||||
// Copyright © 2013-2021 Jiang Yin. All rights reserved.
|
||||
// Homepage: https://gameframework.cn/
|
||||
// Feedback: mailto:ellan@gameframework.cn
|
||||
//------------------------------------------------------------
|
||||
|
||||
using GameFramework;
|
||||
using GameFramework.Event;
|
||||
|
||||
namespace UnityGameFramework.Runtime
|
||||
{
|
||||
/// <summary>
|
||||
/// 资源更新成功事件。
|
||||
/// </summary>
|
||||
public sealed class ResourceUpdateSuccessEventArgs : GameEventArgs
|
||||
{
|
||||
/// <summary>
|
||||
/// 资源更新成功事件编号。
|
||||
/// </summary>
|
||||
public static readonly int EventId = typeof(ResourceUpdateSuccessEventArgs).GetHashCode();
|
||||
|
||||
/// <summary>
|
||||
/// 初始化资源更新成功事件的新实例。
|
||||
/// </summary>
|
||||
public ResourceUpdateSuccessEventArgs()
|
||||
{
|
||||
Name = null;
|
||||
DownloadPath = null;
|
||||
DownloadUri = null;
|
||||
Length = 0;
|
||||
CompressedLength = 0;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取资源更新成功事件编号。
|
||||
/// </summary>
|
||||
public override int Id
|
||||
{
|
||||
get
|
||||
{
|
||||
return EventId;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取资源名称。
|
||||
/// </summary>
|
||||
public string Name
|
||||
{
|
||||
get;
|
||||
private set;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取资源下载后存放路径。
|
||||
/// </summary>
|
||||
public string DownloadPath
|
||||
{
|
||||
get;
|
||||
private set;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取下载地址。
|
||||
/// </summary>
|
||||
public string DownloadUri
|
||||
{
|
||||
get;
|
||||
private set;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取资源大小。
|
||||
/// </summary>
|
||||
public int Length
|
||||
{
|
||||
get;
|
||||
private set;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取压缩后大小。
|
||||
/// </summary>
|
||||
public int CompressedLength
|
||||
{
|
||||
get;
|
||||
private set;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 创建资源更新成功事件。
|
||||
/// </summary>
|
||||
/// <param name="e">内部事件。</param>
|
||||
/// <returns>创建的资源更新成功事件。</returns>
|
||||
public static ResourceUpdateSuccessEventArgs Create(GameFramework.Resource.ResourceUpdateSuccessEventArgs e)
|
||||
{
|
||||
ResourceUpdateSuccessEventArgs resourceUpdateSuccessEventArgs = ReferencePool.Acquire<ResourceUpdateSuccessEventArgs>();
|
||||
resourceUpdateSuccessEventArgs.Name = e.Name;
|
||||
resourceUpdateSuccessEventArgs.DownloadPath = e.DownloadPath;
|
||||
resourceUpdateSuccessEventArgs.DownloadUri = e.DownloadUri;
|
||||
resourceUpdateSuccessEventArgs.Length = e.Length;
|
||||
resourceUpdateSuccessEventArgs.CompressedLength = e.CompressedLength;
|
||||
return resourceUpdateSuccessEventArgs;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 清理资源更新成功事件。
|
||||
/// </summary>
|
||||
public override void Clear()
|
||||
{
|
||||
Name = null;
|
||||
DownloadPath = null;
|
||||
DownloadUri = null;
|
||||
Length = 0;
|
||||
CompressedLength = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: d652343468bb5eb489ea17764743a770
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,71 @@
|
||||
//------------------------------------------------------------
|
||||
// Game Framework
|
||||
// Copyright © 2013-2021 Jiang Yin. All rights reserved.
|
||||
// Homepage: https://gameframework.cn/
|
||||
// Feedback: mailto:ellan@gameframework.cn
|
||||
//------------------------------------------------------------
|
||||
|
||||
using GameFramework;
|
||||
using GameFramework.Event;
|
||||
|
||||
namespace UnityGameFramework.Runtime
|
||||
{
|
||||
/// <summary>
|
||||
/// 资源校验失败事件。
|
||||
/// </summary>
|
||||
public sealed class ResourceVerifyFailureEventArgs : GameEventArgs
|
||||
{
|
||||
/// <summary>
|
||||
/// 资源校验失败事件编号。
|
||||
/// </summary>
|
||||
public static readonly int EventId = typeof(ResourceVerifyFailureEventArgs).GetHashCode();
|
||||
|
||||
/// <summary>
|
||||
/// 初始化资源校验失败事件的新实例。
|
||||
/// </summary>
|
||||
public ResourceVerifyFailureEventArgs()
|
||||
{
|
||||
Name = null;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取资源校验失败事件编号。
|
||||
/// </summary>
|
||||
public override int Id
|
||||
{
|
||||
get
|
||||
{
|
||||
return EventId;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取资源名称。
|
||||
/// </summary>
|
||||
public string Name
|
||||
{
|
||||
get;
|
||||
private set;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 创建资源校验失败事件。
|
||||
/// </summary>
|
||||
/// <param name="e">内部事件。</param>
|
||||
/// <returns>创建的资源校验失败事件。</returns>
|
||||
public static ResourceVerifyFailureEventArgs Create(GameFramework.Resource.ResourceVerifyFailureEventArgs e)
|
||||
{
|
||||
ResourceVerifyFailureEventArgs resourceVerifyFailureEventArgs = ReferencePool.Acquire<ResourceVerifyFailureEventArgs>();
|
||||
resourceVerifyFailureEventArgs.Name = e.Name;
|
||||
return resourceVerifyFailureEventArgs;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 清理资源校验失败事件。
|
||||
/// </summary>
|
||||
public override void Clear()
|
||||
{
|
||||
Name = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 7adfa3d08717d2d4f9ffb7052753a3bc
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,83 @@
|
||||
//------------------------------------------------------------
|
||||
// Game Framework
|
||||
// Copyright © 2013-2021 Jiang Yin. All rights reserved.
|
||||
// Homepage: https://gameframework.cn/
|
||||
// Feedback: mailto:ellan@gameframework.cn
|
||||
//------------------------------------------------------------
|
||||
|
||||
using GameFramework;
|
||||
using GameFramework.Event;
|
||||
|
||||
namespace UnityGameFramework.Runtime
|
||||
{
|
||||
/// <summary>
|
||||
/// 资源校验开始事件。
|
||||
/// </summary>
|
||||
public sealed class ResourceVerifyStartEventArgs : GameEventArgs
|
||||
{
|
||||
/// <summary>
|
||||
/// 资源校验开始事件编号。
|
||||
/// </summary>
|
||||
public static readonly int EventId = typeof(ResourceVerifyStartEventArgs).GetHashCode();
|
||||
|
||||
/// <summary>
|
||||
/// 初始化资源校验开始事件的新实例。
|
||||
/// </summary>
|
||||
public ResourceVerifyStartEventArgs()
|
||||
{
|
||||
Count = 0;
|
||||
TotalLength = 0L;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取资源校验开始事件编号。
|
||||
/// </summary>
|
||||
public override int Id
|
||||
{
|
||||
get
|
||||
{
|
||||
return EventId;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取要校验资源的数量。
|
||||
/// </summary>
|
||||
public int Count
|
||||
{
|
||||
get;
|
||||
private set;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取要校验资源的总大小。
|
||||
/// </summary>
|
||||
public long TotalLength
|
||||
{
|
||||
get;
|
||||
private set;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 创建资源校验开始事件。
|
||||
/// </summary>
|
||||
/// <param name="e">内部事件。</param>
|
||||
/// <returns>创建的资源校验开始事件。</returns>
|
||||
public static ResourceVerifyStartEventArgs Create(GameFramework.Resource.ResourceVerifyStartEventArgs e)
|
||||
{
|
||||
ResourceVerifyStartEventArgs resourceVerifyStartEventArgs = ReferencePool.Acquire<ResourceVerifyStartEventArgs>();
|
||||
resourceVerifyStartEventArgs.Count = e.Count;
|
||||
resourceVerifyStartEventArgs.TotalLength = e.TotalLength;
|
||||
return resourceVerifyStartEventArgs;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 清理资源校验开始事件。
|
||||
/// </summary>
|
||||
public override void Clear()
|
||||
{
|
||||
Count = 0;
|
||||
TotalLength = 0L;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 42cc09d13fb26744ab9fc5da7714f443
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,83 @@
|
||||
//------------------------------------------------------------
|
||||
// Game Framework
|
||||
// Copyright © 2013-2021 Jiang Yin. All rights reserved.
|
||||
// Homepage: https://gameframework.cn/
|
||||
// Feedback: mailto:ellan@gameframework.cn
|
||||
//------------------------------------------------------------
|
||||
|
||||
using GameFramework;
|
||||
using GameFramework.Event;
|
||||
|
||||
namespace UnityGameFramework.Runtime
|
||||
{
|
||||
/// <summary>
|
||||
/// 资源校验成功事件。
|
||||
/// </summary>
|
||||
public sealed class ResourceVerifySuccessEventArgs : GameEventArgs
|
||||
{
|
||||
/// <summary>
|
||||
/// 资源校验成功事件编号。
|
||||
/// </summary>
|
||||
public static readonly int EventId = typeof(ResourceVerifySuccessEventArgs).GetHashCode();
|
||||
|
||||
/// <summary>
|
||||
/// 初始化资源校验成功事件的新实例。
|
||||
/// </summary>
|
||||
public ResourceVerifySuccessEventArgs()
|
||||
{
|
||||
Name = null;
|
||||
Length = 0;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取资源校验成功事件编号。
|
||||
/// </summary>
|
||||
public override int Id
|
||||
{
|
||||
get
|
||||
{
|
||||
return EventId;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取资源名称。
|
||||
/// </summary>
|
||||
public string Name
|
||||
{
|
||||
get;
|
||||
private set;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取资源大小。
|
||||
/// </summary>
|
||||
public int Length
|
||||
{
|
||||
get;
|
||||
private set;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 创建资源校验成功事件。
|
||||
/// </summary>
|
||||
/// <param name="e">内部事件。</param>
|
||||
/// <returns>创建的资源校验成功事件。</returns>
|
||||
public static ResourceVerifySuccessEventArgs Create(GameFramework.Resource.ResourceVerifySuccessEventArgs e)
|
||||
{
|
||||
ResourceVerifySuccessEventArgs resourceVerifySuccessEventArgs = ReferencePool.Acquire<ResourceVerifySuccessEventArgs>();
|
||||
resourceVerifySuccessEventArgs.Name = e.Name;
|
||||
resourceVerifySuccessEventArgs.Length = e.Length;
|
||||
return resourceVerifySuccessEventArgs;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 清理资源校验成功事件。
|
||||
/// </summary>
|
||||
public override void Clear()
|
||||
{
|
||||
Name = null;
|
||||
Length = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 4318e2ddfebdf804eaac67df48fd4a83
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,13 @@
|
||||
//------------------------------------------------------------
|
||||
// Game Framework
|
||||
// Copyright © 2013-2021 Jiang Yin. All rights reserved.
|
||||
// Homepage: https://gameframework.cn/
|
||||
// Feedback: mailto:ellan@gameframework.cn
|
||||
//------------------------------------------------------------
|
||||
|
||||
namespace UnityGameFramework.Runtime
|
||||
{
|
||||
internal sealed class SceneAsset
|
||||
{
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: ed139c50a07e4544eb7ff7e75654d488
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Reference in New Issue
Block a user