Class CatalogItemAsset
Base class for most of the static data in Game Foundation.
Inherited Members
Namespace: UnityEngine.GameFoundation.DefaultCatalog
Syntax
public abstract class CatalogItemAsset : ScriptableObject, ISerializationCallbackReceiver
Properties
displayName
The readable name of this CatalogItemAsset instance. It is used to make the Editor more comfortable, but it can also be used at runtime to display a readable information to the players.
Declaration
public ExternalizableValue<string> displayName { get; }
Property Value
Type | Description |
---|---|
ExternalizableValue<String> |
key
The identifier of the CatalogItem constructed from this asset.
Declaration
public string key { get; }
Property Value
Type | Description |
---|---|
String |
Methods
Awake()
Initializes the internal collections.
Declaration
protected void Awake()
AwakeDefinition()
Overriden by inherited classes to initialize specific members.
Declaration
protected virtual void AwakeDefinition()
ConfigureItem(CatalogBuilder, IExternalValueProvider)
Configures a specified builder
with the specifics
of this item.
Declaration
protected abstract CatalogItemConfig ConfigureItem(CatalogBuilder builder, IExternalValueProvider valueProvider)
Parameters
Type | Name | Description |
---|---|---|
CatalogBuilder | builder | The target builder. |
IExternalValueProvider | valueProvider | A value provider to override some catalog item's data with an external source. |
Returns
Type | Description |
---|---|
CatalogItemConfig | The item config. |
DeserializeListsToDictionary<TKey, TValue>(List<TKey>, List<TValue>, Dictionary<TKey, TValue>)
Deserialize the given lists into the given dictionary.
Declaration
protected static void DeserializeListsToDictionary<TKey, TValue>(List<TKey> keys, List<TValue> values, Dictionary<TKey, TValue> container)
Parameters
Type | Name | Description |
---|---|---|
List<TKey> | keys | A list of keys. It is cleared after the dictionary has been filled. |
List<TValue> | values | A list of values. It is cleared after the dictionary has been filled. |
Dictionary<TKey, TValue> | container | The dictionary that will be filled with serialized data. It is cleared even if the given lists are empty. |
Type Parameters
Name | Description |
---|---|
TKey | The type of the |
TValue | The type of the |
Exceptions
Type | Condition |
---|---|
ArgumentNullException | Thrown if any of the argument is null. |
SerializationException | Thrown if the given lists have a different item count. |
DeserializeListsToDictionary<TKey, TValue>(List<TKey>, List<TValue>, Dictionary<TKey, ExternalizableValue<TValue>>)
Deserialize the given lists into the given dictionary.
Declaration
protected static void DeserializeListsToDictionary<TKey, TValue>(List<TKey> keys, List<TValue> values, Dictionary<TKey, ExternalizableValue<TValue>> container)
Parameters
Type | Name | Description |
---|---|---|
List<TKey> | keys | A list of keys. It is cleared after the dictionary has been filled. |
List<TValue> | values | A list of values. It is cleared after the dictionary has been filled. |
Dictionary<TKey, ExternalizableValue<TValue>> | container |
Type Parameters
Name | Description |
---|---|
TKey | The type of the |
TValue | The type of the |
Exceptions
Type | Condition |
---|---|
ArgumentNullException | Thrown if any of the argument is null. |
SerializationException | Thrown if the given lists have a different item count. |
GetStaticProperties()
Get all static properties stored in this item.
Declaration
public List<PropertyData> GetStaticProperties()
Returns
Type | Description |
---|---|
List<PropertyData> | Return a list of PropertyData for each properties stored in this item. The returned list is never null. |
GetTags(ICollection<TagAsset>, Boolean)
Fills the given target
collection with all the TagAsset
instances linked to this CatalogItemAsset instance.
Declaration
public int GetTags(ICollection<TagAsset> target = null, bool clearTarget = true)
Parameters
Type | Name | Description |
---|---|---|
ICollection<TagAsset> | target | The target container of all the TagAsset instances. |
Boolean | clearTarget | If |
Returns
Type | Description |
---|---|
Int32 | The number of TagAsset instances linked to this CatalogItemAsset instance. |
HasTag(TagAsset)
Tells whether or not the given tag
is within
this CatalogItemAsset instance.
Declaration
public bool HasTag(TagAsset tag)
Parameters
Type | Name | Description |
---|---|---|
TagAsset | tag | The TagAsset instance to search for. |
Returns
Type | Description |
---|---|
Boolean | Whether or not this CatalogItemAsset instance has the specified TagAsset included. |
Exceptions
Type | Condition |
---|---|
ArgumentNullException | If the |
OnAfterItemDeserialize()
Called at the end of OnAfterDeserialize. Enable inheritance to add specific deserialization process.
Declaration
protected virtual void OnAfterItemDeserialize()
OnBeforeItemSerialize()
Called at the end of OnBeforeSerialize. Enable inheritance to add specific serialization process.
Declaration
protected virtual void OnBeforeItemSerialize()
TryGetStaticProperty(String, out Property)
Try to get the value of the static property with the given propertyKey
.
Declaration
public bool TryGetStaticProperty(string propertyKey, out Property property)
Parameters
Type | Name | Description |
---|---|---|
String | propertyKey | Identifier of the static property to get the value of. |
Property | property | The value of the searched static property, if found. |
Returns
Type | Description |
---|---|
Boolean | Returns true if a static property with the given |
Explicit Interface Implementations
ISerializationCallbackReceiver.OnAfterDeserialize()
Called after serialization, this will deserialize the UnityEngine.GameFoundation.DefaultCatalog.CatalogItemAsset.m_StaticPropertyKeys and UnityEngine.GameFoundation.DefaultCatalog.CatalogItemAsset.m_StaticPropertyValues lists and convert them into a dictionary UnityEngine.GameFoundation.DefaultCatalog.CatalogItemAsset.staticProperties.
Declaration
void ISerializationCallbackReceiver.OnAfterDeserialize()
Implements
ISerializationCallbackReceiver.OnBeforeSerialize()
Called before serialization, this will copy over all keys and values from the UnityEngine.GameFoundation.DefaultCatalog.CatalogItemAsset.staticProperties dictionary into their serializable lists UnityEngine.GameFoundation.DefaultCatalog.CatalogItemAsset.m_StaticPropertyKeys and UnityEngine.GameFoundation.DefaultCatalog.CatalogItemAsset.m_StaticPropertyValues.
Declaration
void ISerializationCallbackReceiver.OnBeforeSerialize()