using System;
using UnityEngine.Assertions;
namespace UnityEngine.Rendering.HighDefinition
{
///
/// Define a value that can be either customized or fetched from a current quality settings' sub level.
///
/// If you intend to serialize this type, use specialized version instead. ().
///
/// The type of the scalable setting.
[Serializable]
public class ScalableSettingValue
{
[SerializeField]
private T m_Override;
[SerializeField]
private bool m_UseOverride;
[SerializeField]
private int m_Level;
/// The level to use in the associated .
public int level
{
get => m_Level;
set => m_Level = value;
}
/// Defines whether the value is used or not.
public bool useOverride
{
get => m_UseOverride;
set => m_UseOverride = value;
}
/// The value to use when is true.
public T @override
{
get => m_Override;
set => m_Override = value;
}
/// Resolve the actual value to use.
/// The scalable setting to use whne resolving level values. Must not be null.
///
/// The value if is true is returned
/// Otherwise the level value of for is returned.
///
public T Value(ScalableSetting source) => m_UseOverride || source == null ? m_Override : source[m_Level];
/// Copy the values of this instance to .
/// The target of the copy. Must not be null.
public void CopyTo(ScalableSettingValue target)
{
Assert.IsNotNull(target);
target.m_Override = m_Override;
target.m_UseOverride = m_UseOverride;
target.m_Level = m_Level;
}
}
#region Specialized Scalable Setting Value
// We define explicitly specialized version of the ScalableSettingValue so it can be serialized with
// Unity's serialization API.
/// An int scalable setting value
[Serializable] public class IntScalableSettingValue : ScalableSettingValue {}
/// An uint scalable setting value
[Serializable] public class UintScalableSettingValue : ScalableSettingValue {}
/// An float scalable setting value
[Serializable] public class FloatScalableSettingValue : ScalableSettingValue {}
/// An bool scalable setting value
[Serializable] public class BoolScalableSettingValue : ScalableSettingValue {}
#endregion
}