namespace Zinnia.Pattern
{
using UnityEngine;
using Zinnia.Extension;
///
/// Matches the name of the selected property.
///
public class ApplicationPatternMatcher : PatternMatcher
{
///
/// The property source.
///
public enum Source
{
///
/// The whether the application is in editor mode.
///
IsEditor,
///
/// The whether the application currently has user focus.
///
IsFocused,
///
/// The application platform.
///
Platform,
///
/// The language of the operating system the application is running on.
///
SystemLanguage,
///
/// The version of Unity the application is built in.
///
UnityVersion
}
[Tooltip("The source property to match against.")]
[SerializeField]
private Source propertySource;
///
/// The source property to match against.
///
public Source PropertySource
{
get
{
return propertySource;
}
set
{
propertySource = value;
if (this.IsMemberChangeAllowed())
{
OnAfterPropertySourceChange();
}
}
}
///
/// Sets the .
///
/// The index of the .
public virtual void SetPropertySource(int index)
{
PropertySource = EnumExtensions.GetByIndex(index);
}
///
protected override string DefineSourceString()
{
switch (PropertySource)
{
case Source.IsEditor:
return Application.isEditor.ToString();
case Source.IsFocused:
return Application.isFocused.ToString();
case Source.Platform:
return Application.platform.ToString();
case Source.SystemLanguage:
return Application.systemLanguage.ToString();
case Source.UnityVersion:
return Application.unityVersion.ToString();
}
return null;
}
///
/// Called after has been changed.
///
protected virtual void OnAfterPropertySourceChange()
{
ProcessSourceString();
}
}
}