using System; using UnityEditor; using UnityEngine; namespace UnityEditor.XR.Management { /// /// Custom attribute that indicates a class supports the for a /// specific loader and build target group. Any class marked with this attribute will /// have methods called on it while the XR Plug-in Management UI is displaying /// the supported loader for the supported build target. /// /// Note that there can only be one custom loader for each (Loader Type, BuildTargetGroup) combination. If more than one loader exists, /// the system will fall back to built-in supported rendering and log a warning in the Console window. /// [AttributeUsage(AttributeTargets.Class, AllowMultiple = true)] public class XRCustomLoaderUIAttribute : Attribute { /// /// Supported build target group. /// /// Supported build target group. public BuildTargetGroup buildTargetGroup { get; set; } /// /// Supported loader type. /// /// Supported loader type. public string loaderTypeName { get; set; } private XRCustomLoaderUIAttribute() {} /// /// Constructor for this attribute. /// /// Loader type name. /// Build Target Group. public XRCustomLoaderUIAttribute(string loaderTypeName, BuildTargetGroup buildTargetGroup) { this.loaderTypeName = loaderTypeName; this.buildTargetGroup = buildTargetGroup; } } /// /// Custom interface provided by the package if the package uses /// its own UI in the XR Plug-in Management loader selection /// window. /// /// Any class that implements this interface must be tagged with the attribute. /// public interface IXRCustomLoaderUI { /// /// Current enabled state of this loader. /// /// True if the loader has been enabled, false otherwise. bool IsLoaderEnabled { get; set; } /// /// Array of type names that are incompatible with the loader when it's enabled. Non-compatible loaders will be grayed out /// in the UI. /// /// Array of type names to disable. string[] IncompatibleLoaders { get; } /// /// The height of the area within the UI that this renderer will need to render its UI. This height will be the height of the rect passed into the call. /// This should return a a non-zero value that's a multiple of the line height set in . /// /// Non-zero multiple of the line height set in . If this is 0, the rect passed to will be the default line height. float RequiredRenderHeight { get; } /// /// The Rendering component passes the expected line height to the custom renderer. This allows the component to /// calculate the necessary area height required to render the custom UI into the component space. The calculated value should /// be returned from the . /// /// void SetRenderedLineHeight(float height); /// /// Allows XR Plug-in Management to tell the UI which build target group it's being used with. /// /// Build target that this instance handles. BuildTargetGroup ActiveBuildTargetGroup { get; set; } /// /// Call to render the UI for this custom loader. /// /// The rect within which the UI should render into. void OnGUI(Rect rect); } }