WuhuIslandTesting/Library/PackageCache/com.unity.addressables@1.21.12/Runtime/ResourceManager/ResourceProviders/BinaryAssetProvider.cs

25 lines
977 B
C#
Raw Permalink Normal View History

2025-01-07 02:06:59 +01:00
using System;
using System.ComponentModel;
using UnityEngine.ResourceManagement.Util;
namespace UnityEngine.ResourceManagement.ResourceProviders
{
/// <summary>
/// Converts ray binary data into the requested object.
/// </summary>
[DisplayName("Binary Asset Provider")]
internal class BinaryAssetProvider<TAdapter> : BinaryDataProvider where TAdapter : BinaryStorageBuffer.ISerializationAdapter, new()
{
/// <summary>
/// Converts raw bytes into requested object type via BinaryStorageBuffer.ISerializationAdapter
/// </summary>
/// <param name="type">The object type the text is converted to.</param>
/// <param name="data">The data to convert.</param>
/// <returns>Returns the converted object.</returns>
public override object Convert(Type type, byte[] data)
{
return new BinaryStorageBuffer.Reader(data, 512, new TAdapter()).ReadObject(type, 0, false);
}
}
}