/// <summary>Abstract class that is used by systems to encapsulate Sprite data representation. Currently this is used by Sprite Editor Window.</summary>
[Serializable]
publicclassSpriteRect
{
[SerializeField]
stringm_Name;
[SerializeField]
stringm_OriginalName;
[SerializeField]
Vector2m_Pivot;
[SerializeField]
SpriteAlignmentm_Alignment;
[SerializeField]
Vector4m_Border;
[SerializeField]
Rectm_Rect;
[SerializeField]
stringm_SpriteID;
[SerializeField]
internallongm_InternalID;
internalboolm_RegisterInternalID;
GUIDm_GUID;
// <summary>The name of the Sprite data.</summary>
publicstringname
{
get{returnm_Name;}
set{m_Name=value;}
}
// <summary>Vector2value representing the pivot for the Sprite data.</summary>
publicVector2pivot
{
get{returnm_Pivot;}
set{m_Pivot=value;}
}
/// <summary>SpriteAlignment that represents the pivot value for the Sprite data.</summary>
publicSpriteAlignmentalignment
{
get{returnm_Alignment;}
set{m_Alignment=value;}
}
/// <summary>Returns a Vector4 that represents the border of the Sprite data.</summary>
publicVector4border
{
get{returnm_Border;}
set{m_Border=value;}
}
// <summary>Rect value that represents the position and size of the Sprite data.</summary>
publicRectrect
{
get{returnm_Rect;}
set{m_Rect=value;}
}
internalstringoriginalName
{
get
{
if(m_OriginalName==null)
{
m_OriginalName=name;
}
returnm_OriginalName;
}
set{m_OriginalName=value;}
}
// <summary>GUID to uniquely identify the SpriteRect data. This will be populated to Sprite.spriteID to identify the SpriteRect used to generate the Sprite.</summary>
publicGUIDspriteID
{
get
{
ValidateGUID();
returnm_GUID;
}
set
{
m_GUID=value;
m_SpriteID=m_GUID.ToString();
ValidateGUID();
}
}
privatevoidValidateGUID()
{
if(m_GUID.Empty())
{
// We can't use ISerializationCallbackReceiver because we will hit into Script serialization errors
m_GUID=newGUID(m_SpriteID);
if(m_GUID.Empty())
{
m_GUID=GUID.Generate();
m_SpriteID=m_GUID.ToString();
}
}
}
/// <summary>Helper method to get SpriteRect.spriteID from a SerializedProperty.</summary>
/// <param name="sp">The SerializedProperty to acquire from.</param>