using System;
using UnityEngine;
using UnityEngine.Serialization;
using UnityEngine.TextCore;
namespace TMPro
{
// Base class inherited by the various TextMeshPro Assets.
[Serializable]
public abstract class TMP_Asset : ScriptableObject
{
///
/// The version of the text asset class.
/// Version 1.1.0 introduces new data structure to be compatible with new font asset structure.
///
public string version
{
get { return m_Version; }
internal set { m_Version = value; }
}
///
/// Instance ID of the TMP Asset
///
public int instanceID
{
get
{
if (m_InstanceID == 0)
m_InstanceID = GetInstanceID();
return m_InstanceID;
}
}
///
/// HashCode based on the name of the asset.
///
public int hashCode
{
get
{
if (m_HashCode == 0)
m_HashCode = TMP_TextUtilities.GetHashCode(name);
return m_HashCode;
}
set => m_HashCode = value;
}
///
/// Information about the face of the asset.
///
public FaceInfo faceInfo
{
get { return m_FaceInfo; }
set { m_FaceInfo = value; }
}
///
/// The material used by this asset.
///
public Material material
{
get => m_Material;
set => m_Material = value;
}
///
/// HashCode based on the name of the material assigned to this asset.
///
public int materialHashCode
{
get
{
if (m_MaterialHashCode == 0)
{
if (m_Material == null)
return 0;
m_MaterialHashCode = TMP_TextUtilities.GetSimpleHashCode(m_Material.name);
}
return m_MaterialHashCode;
}
set => m_MaterialHashCode = value;
}
// =============================================
// Private backing fields for public properties.
// =============================================
[SerializeField]
internal string m_Version;
internal int m_InstanceID;
internal int m_HashCode;
[SerializeField]
internal FaceInfo m_FaceInfo;
[SerializeField][FormerlySerializedAs("material")]
internal Material m_Material;
internal int m_MaterialHashCode;
}
}