GuidReference
The GuidReference system is a data association tool in IdleKit for visualizing relationships between different IEntityData
(e.g., ICurrencyData
contains a GuidReference to IRarityData
). They provide optional C# attributes that the user can use to link to other IEntityData
in a dropdown (as shown below).
GuidReferenceAttribute
This attribute provides a link to a type of IEntityData
via an identifier. It is used by the GuidReferenceHelper
to link data together without using a hard reference.
e.g: Links the rarityId
to an IGuidReferenceableAsset
marked with GuidReferenceable(typeof(IRarityData))
[Serializable]
public class CurrencyData : ICurrencyData
{
...
[SerializeField, GuidReference(typeof(IRarityData))]
protected string _rarityId;
public virtual string rarityId => _rarityId;
...
}
}
GuidReferenceableAttribute
A customized attribute that helps to identify the IEntityData
associated with the EntityDataAsset
. The attribute enables other IEntityData
to be able to link with the IEntityData
in this EntityDataAsset
with a GuidReference
attribute.
e.g., Enables this IRarityData
to be linkable in the CurrencyData
[GuidReferenceable(typeof(RarityData))]
public class RarityDataAsset : ScriptableObject, IRarityDataAsset<IRarityData>
{
[SerializeField]
protected RarityData _data;
public virtual IRarityData data => _data;
public virtual string id => _data.id;
}
IGuidReferenceableAsset
The interface that marks the ScriptableObject-based EntityDataAssets
.
GuidReferenceHelper
It contains an important Unity menu items [MenuItem("IdleKit/Guids/Force Update")]
. The method helps re-establish GuidReference links between the EntityDataAssets
.
GuidReferenceDrawer
Used by the EntityDataAssets
to render the GuidReference
links in Unity inspector.