namespace Zinnia.Pattern { using UnityEngine; using Zinnia.Extension; /// /// Matches the name of the current . /// public class SystemInfoPatternMatcher : PatternMatcher { /// /// The property source. /// public enum Source { /// /// The current battery level. /// BatteryLevel, /// /// The current battery status. /// BatteryStatus, /// /// The current device model. /// DeviceModel, /// /// The current device name. /// DeviceName, /// /// The current device type. /// DeviceType, /// /// The current device unique identifier. /// DeviceUniqueIdentifier, /// /// The current id of graphics device. /// GraphicsDeviceID, /// /// The current name of graphics device. /// GraphicsDeviceName, /// /// The current type of graphics device. /// GraphicsDeviceType, /// /// The current vendor of graphics device. /// GraphicsDeviceVendor, /// /// The current vendor id of graphics device. /// GraphicsDeviceVendorID, /// /// The current version of graphics device. /// GraphicsDeviceVersion, /// /// The current amount of graphics memory. /// GraphicsMemorySize, /// /// Whether the graphics device multi-threaded. /// GraphicsMultiThreaded, /// /// The current shader level of the graphics device. /// GraphicsShaderLevel, /// /// The maximum cubemap texture size. /// MaxCubemapSize, /// /// The maximum texture size. /// MaxTextureSize, /// /// The current device operating system and version. /// OperatingSystem, /// /// The current device operating system family. /// OperatingSystemFamily, /// /// The current device processor count. /// ProcessorCount, /// /// The current device processor frequency. /// ProcessorFrequency, /// /// The current device processor type. /// ProcessorType, /// /// Whether the current device has an accelerometer. /// SupportsAccelerometer, /// /// Whether the current device has an audio playback device. /// SupportsAudio, /// /// Whether the current device has a gyroscope. /// SupportsGyroscope, /// /// Whether the current graphics device supports draw call instancing. /// SupportsInstancing, /// /// Whether the current device can report its location. /// SupportsLocationService, /// /// Whether the current device supports haptic feedback. /// SupportsVibration, /// /// The current amount of device memory. /// SystemMemorySize } [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.BatteryLevel: return SystemInfo.batteryLevel.ToString(); case Source.BatteryStatus: return SystemInfo.batteryStatus.ToString(); case Source.DeviceModel: return SystemInfo.deviceModel; case Source.DeviceName: return SystemInfo.deviceName; case Source.DeviceType: return SystemInfo.deviceType.ToString(); case Source.DeviceUniqueIdentifier: return SystemInfo.deviceUniqueIdentifier; case Source.GraphicsDeviceID: return SystemInfo.graphicsDeviceID.ToString(); case Source.GraphicsDeviceName: return SystemInfo.graphicsDeviceName; case Source.GraphicsDeviceType: return SystemInfo.graphicsDeviceType.ToString(); case Source.GraphicsDeviceVendor: return SystemInfo.graphicsDeviceVendor; case Source.GraphicsDeviceVendorID: return SystemInfo.graphicsDeviceVendorID.ToString(); case Source.GraphicsDeviceVersion: return SystemInfo.graphicsDeviceVersion; case Source.GraphicsMemorySize: return SystemInfo.graphicsMemorySize.ToString(); case Source.GraphicsMultiThreaded: return SystemInfo.graphicsMultiThreaded.ToString(); case Source.GraphicsShaderLevel: return SystemInfo.graphicsShaderLevel.ToString(); case Source.MaxCubemapSize: return SystemInfo.maxCubemapSize.ToString(); case Source.MaxTextureSize: return SystemInfo.maxTextureSize.ToString(); case Source.OperatingSystem: return SystemInfo.operatingSystem; case Source.OperatingSystemFamily: return SystemInfo.operatingSystemFamily.ToString(); case Source.ProcessorCount: return SystemInfo.processorCount.ToString(); case Source.ProcessorFrequency: return SystemInfo.processorFrequency.ToString(); case Source.ProcessorType: return SystemInfo.processorType; case Source.SupportsAccelerometer: return SystemInfo.supportsAccelerometer.ToString(); case Source.SupportsAudio: return SystemInfo.supportsAudio.ToString(); case Source.SupportsGyroscope: return SystemInfo.supportsGyroscope.ToString(); case Source.SupportsInstancing: return SystemInfo.supportsInstancing.ToString(); case Source.SupportsLocationService: return SystemInfo.supportsLocationService.ToString(); case Source.SupportsVibration: return SystemInfo.supportsVibration.ToString(); case Source.SystemMemorySize: return SystemInfo.systemMemorySize.ToString(); } return null; } /// /// Called after has been changed. /// protected virtual void OnAfterPropertySourceChange() { ProcessSourceString(); } } }