Firstborn/Library/PackageCache/com.unity.ads@3.7.5/Runtime/Monetization/MetaData.cs

47 lines
1.2 KiB
C#
Raw Normal View History

2023-03-28 13:24:16 -04:00
using System.Collections.Generic;
namespace UnityEngine.Monetization
{
/// <summary>
/// Class for sending various metadata to UnityAds.
/// </summary>
public sealed class MetaData : Dictionary<string, object>
{
/// <summary>
/// Metadata category.
/// </summary>
public string category { get; }
/// <summary>
/// Constructs an metadata instance that can be passed to the Advertisement class.
/// </summary>
public MetaData(string category)
{
this.category = category;
}
/// <summary>
/// Sets new metadata fields.
/// </summary>
/// <param name="key">Metadata key.</param>
/// <param name="value">Metadata value. Must be JSON serializable.</param>
public void Set(string key, object value)
{
this[key] = value;
}
/// <summary>
/// Returns the stored metadata key.
/// </summary>
public object Get(string key)
{
return this[key];
}
internal string ToJSON()
{
return MiniJSON.Json.Serialize(this);
}
}
}