namespace Zinnia.Pattern { using UnityEngine; using UnityEngine.XR; using Zinnia.Extension; /// /// Matches the name of the selected property. /// public class XRSettingsPatternMatcher : PatternMatcher { /// /// The property source. /// public enum Source { /// /// The device eye texture demension. /// DeviceEyeTextureDimension, /// /// The eye texture height. /// EyeTextureHeight, /// /// The eye texture resolution scale. /// EyeTextureResolutionScale, /// /// The eye texture resolution width. /// EyeTextureWidth, /// /// The device active state. /// IsDeviceActive, /// /// The loaded device name. /// LoadedDeviceName, /// /// The stereo rendering mode. /// StereoRenderingMode } [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.DeviceEyeTextureDimension: return XRSettings.deviceEyeTextureDimension.ToString(); case Source.EyeTextureHeight: return XRSettings.eyeTextureHeight.ToString(); case Source.EyeTextureResolutionScale: return XRSettings.eyeTextureResolutionScale.ToString(); case Source.EyeTextureWidth: return XRSettings.eyeTextureWidth.ToString(); case Source.IsDeviceActive: return XRSettings.isDeviceActive.ToString(); case Source.LoadedDeviceName: return XRSettings.loadedDeviceName; case Source.StereoRenderingMode: return XRSettings.stereoRenderingMode.ToString(); } return null; } /// /// Called after has been changed. /// protected virtual void OnAfterPropertySourceChange() { ProcessSourceString(); } } }