using System;
using UnityEngine;
namespace VoxelBusters.CoreLibrary.NativePlugins
{
///
/// Object represents an immutable, read-only object that combines a string value with a platform.
///
[Serializable]
public class PlatformConstant
{
#region Fields
[SerializeField]
private NativePlatform m_platform = NativePlatform.Unknown;
[SerializeField]
private string m_value = string.Empty;
#endregion
#region Properties
///
/// Gets the runtime platform associated with string value.
///
/// The enum value indicates the platform to which string value belongs.
public NativePlatform Platform
{
get
{
return m_platform;
}
}
///
/// Gets the string value.
///
/// The string value.
public string Value
{
get
{
return m_value;
}
}
#endregion
#region Constructors
public PlatformConstant(NativePlatform platform, string value)
{
// set properties
m_platform = platform;
m_value = value;
}
#endregion
#region Static methods
///
/// Returns a new instance of , containing a string value functional only on iOS platform.
///
/// The instance of .
/// The string value associated with iOS platform.
public static PlatformConstant iOS(string value)
{
return new PlatformConstant(NativePlatform.iOS, value);
}
///
/// Returns a new instance of , containing a string value functional only on tvOS platform.
///
/// The instance of .
/// The string value associated with tvOS platform.
public static PlatformConstant tvOS(string value)
{
return new PlatformConstant(NativePlatform.tvOS, value);
}
///
/// Returns a new instance of , containing a string value functional only on Android platform.
///
/// The instance of .
/// The string value associated with Android platform.
public static PlatformConstant Android(string value)
{
return new PlatformConstant(NativePlatform.Android, value);
}
///
/// Returns a new instance of , containing a string value functional on all supported platform.
///
/// The instance of .
/// The string value associated with all supported platforms.
public static PlatformConstant All(string value)
{
return new PlatformConstant(NativePlatform.All, value);
}
///
/// Returns a new instance of , containing a string value associated with active platform.
///
/// The instance of .
/// The string value associated with active platform.
public static PlatformConstant Current(string value)
{
var currentPlatform = PlatformMappingServices.GetActivePlatform();
return new PlatformConstant(currentPlatform, value);
}
#endregion
#region Public methods
public bool IsEqualToPlatform(NativePlatform other)
{
return ((other & m_platform) != 0);
}
#endregion
#region Base class methods
public override string ToString()
{
return m_value;
}
#endregion
}
}