using System;
using UnityEngine.ResourceManagement.Util;
using UnityEngine.Serialization;
namespace UnityEngine.AddressableAssets.ResourceLocators
{
///
/// Serializable location data. This is used for the locations of the content catalogs.
///
[Serializable]
public class ResourceLocationData
{
[FormerlySerializedAs("m_keys")]
[SerializeField]
string[] m_Keys;
///
/// The collection of keys for this location.
///
public string[] Keys { get { return m_Keys; } }
[FormerlySerializedAs("m_internalId")]
[SerializeField]
string m_InternalId;
///
/// The internal id.
///
public string InternalId { get { return m_InternalId; } }
[FormerlySerializedAs("m_provider")]
[SerializeField]
string m_Provider;
///
/// The provider id.
///
public string Provider { get { return m_Provider; } }
[FormerlySerializedAs("m_dependencies")]
[SerializeField]
string[] m_Dependencies;
///
/// The collection of dependencies for this location.
///
public string[] Dependencies { get { return m_Dependencies; } }
[SerializeField]
SerializedType m_ResourceType;
///
/// The type of the resource for the location.
///
public Type ResourceType { get { return m_ResourceType.Value; } }
[SerializeField]
byte[] SerializedData;
object _Data;
///
/// The optional arbitrary data stored along with location
///
public object Data
{
get
{
if (_Data == null)
{
if (SerializedData == null || SerializedData.Length <= 0)
return null;
_Data = Utility.SerializationUtilities.ReadObjectFromByteArray(SerializedData, 0);
}
return _Data;
}
set
{
var tmp = new System.Collections.Generic.List();
Utility.SerializationUtilities.WriteObjectToByteList(value, tmp);
SerializedData = tmp.ToArray();
}
}
///
/// Construct a new ResourceLocationData object.
///
/// Array of keys for the location. This must contain at least one item.
/// The internal id.
/// The provider id.
/// The resource object type.
/// Optional array of dependencies.
public ResourceLocationData(string[] keys, string id, Type provider, Type t, string[] dependencies = null)
{
m_Keys = keys;
m_InternalId = id;
m_Provider = provider == null ? "" : provider.FullName;
m_Dependencies = dependencies == null ? new string[0] : dependencies;
m_ResourceType = new SerializedType() { Value = t };
}
}
}