using System;
namespace UnityEngine.Build.Pipeline
{
///
/// Struct containing detailed information about a built asset bundle.
///
[Serializable]
public struct BundleDetails : IEquatable
{
[SerializeField]
string m_FileName;
[SerializeField]
uint m_Crc;
[SerializeField]
string m_Hash;
[SerializeField]
string[] m_Dependencies;
///
/// Specific file name on disk of the asset bundle.
///
public string FileName
{
get { return m_FileName; }
set { m_FileName = value; }
}
///
/// Cyclic redundancy check of the content contained inside of the asset bundle.
/// This value will not change between identical asset bundles with different compression options.
///
public uint Crc
{
get { return m_Crc; }
set { m_Crc = value; }
}
///
/// The hash version of the content contained inside of the asset bundle.
/// This value will not change between identical asset bundles with different compression options.
///
public Hash128 Hash
{
get { return Hash128.Parse(m_Hash); }
set { m_Hash = value.ToString(); }
}
///
/// The array of all dependent asset bundles for this asset bundle.
///
public string[] Dependencies
{
get { return m_Dependencies; }
set { m_Dependencies = value; }
}
///
/// Determines if the current bundle details instance is equivalent the specified bundle details.
///
/// The bundle details to compare to.
/// Returns true if the bundle details are equivalent. Returns false otherwise.
public override bool Equals(object obj)
{
if (ReferenceEquals(null, obj))
return false;
return obj is BundleDetails && Equals((BundleDetails)obj);
}
///
/// Creates the hash code of the bundle information.
///
/// Returns the created hash code.
public override int GetHashCode()
{
unchecked
{
var hashCode = (FileName != null ? FileName.GetHashCode() : 0);
hashCode = (hashCode * 397) ^ (int)Crc;
hashCode = (hashCode * 397) ^ Hash.GetHashCode();
hashCode = (hashCode * 397) ^ (Dependencies != null ? Dependencies.GetHashCode() : 0);
return hashCode;
}
}
///
public static bool operator==(BundleDetails a, BundleDetails b)
{
return a.Equals(b);
}
///
public static bool operator!=(BundleDetails a, BundleDetails b)
{
return !(a == b);
}
///
/// Determines if the current instance is equivalent to the specified bundle details object.
///
/// The object to compare to.
/// Returns true if the bundle details objects are equivalent. Returns false otherwise.
public bool Equals(BundleDetails other)
{
return string.Equals(FileName, other.FileName) && Crc == other.Crc && Hash.Equals(other.Hash) && Equals(Dependencies, other.Dependencies);
}
}
}