XRCustomLoaderUI.cs
4.13 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
using System;
using UnityEditor;
using UnityEngine;
namespace UnityEditor.XR.Management
{
/// <summary>
/// Custom attribute that indicates a class supports the <see cref="IXRCustomLoaderUI"/> for a
/// specific loader and build target group. Any class marked with this attribute will
/// have <see cref="IXRCustomLoaderUI"/> 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.
/// </summary>
[AttributeUsage(AttributeTargets.Class, AllowMultiple = true)]
public class XRCustomLoaderUIAttribute : Attribute
{
/// <summary>
/// Supported build target group.
/// </summary>
/// <value>Supported build target group. </value>
public BuildTargetGroup buildTargetGroup { get; set; }
/// <summary>
/// Supported loader type.
/// </summary>
/// <value>Supported loader type.</value>
public string loaderTypeName { get; set; }
private XRCustomLoaderUIAttribute() {}
/// <summary>
/// Constructor for this attribute.
/// </summary>
/// <param name="loaderTypeName">Loader type name.</param>
/// <param name="buildTargetGroup">Build Target Group.</param>
public XRCustomLoaderUIAttribute(string loaderTypeName, BuildTargetGroup buildTargetGroup)
{
this.loaderTypeName = loaderTypeName;
this.buildTargetGroup = buildTargetGroup;
}
}
/// <summary>
/// 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 <see cref="XRCustomLoaderUIAttribute"/> attribute.
/// </summary>
public interface IXRCustomLoaderUI
{
/// <summary>
/// Current enabled state of this loader.
/// </summary>
/// <value>True if the loader has been enabled, false otherwise.</value>
bool IsLoaderEnabled { get; set; }
/// <summary>
/// Array of type names that are incompatible with the loader when it's enabled. Non-compatible loaders will be grayed out
/// in the UI.
/// </summary>
/// <value>Array of type names to disable.</value>
string[] IncompatibleLoaders { get; }
/// <summary>
/// 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 <see cref="OnGUI"/> call.
/// This should return a a non-zero value that's a multiple of the line height set in <see cref="SetRenderedLineHeight"/>.
/// </summary>
/// <value>Non-zero multiple of the line height set in <see cref="SetRenderedLineHeight"/>. If this is 0, the rect passed to <see cref="OnGUI"/> will be the default line height.</value>
float RequiredRenderHeight { get; }
/// <summary>
/// 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 <see cref="RequiredRenderHeight"/>.
/// </summary>
/// <param name="height"></param>
void SetRenderedLineHeight(float height);
/// <summary>
/// Allows XR Plug-in Management to tell the UI which build target group it's being used with.
/// </summary>
/// <value>Build target that this instance handles.</value>
BuildTargetGroup ActiveBuildTargetGroup { get; set; }
/// <summary>
/// Call to render the UI for this custom loader.
/// </summary>
/// <param name="rect">The rect within which the UI should render into.</param>
void OnGUI(Rect rect);
}
}