-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathXRSessionFeatureEditor.cs
95 lines (83 loc) · 3.75 KB
/
XRSessionFeatureEditor.cs
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
// <copyright file="XRSessionFeatureEditor.cs" company="Google LLC">
//
// Copyright 2024 Google LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
// </copyright>
//-----------------------------------------------------------------------
namespace Google.XR.Extensions.Editor.Internal
{
using UnityEditor;
using UnityEngine;
/// <summary>
/// Custom Editor for <see cref="XRSessionFeature"/>.
/// </summary>
[CustomEditor(typeof(XRSessionFeature))]
internal class XRSessionFeatureEditor : Editor
{
private const string _immersiveXRFieldName = "ImmersiveXR";
private const string _immersiveXRTooltip =
"Indicate that the activity starts as XR Immersive app, " +
"and will be launched in full-screen mode.";
private const string _subsamplingFieldName = "_vulkanSubsampling";
private const string _subsamplingTooltip =
"Enable Subsampling (Vulkan) to reduce memory bandwidth on foveated framebuffers. " +
"It only takes effect when Foveated Rendering feature is in use.";
private const string _spacewarpFieldName = "_spacewarp";
#if UNITY_6000_0_23_OR_NEWER
private const string _spacewarpTooltip =
"Enable URP Spacewarp (Vulkan) to unlock extra computation power for suitable content.";
#else
private const string _spacewarpTooltip =
"Enable URP Spacewarp (Vulkan) to unlock extra computation power for suitable content."
+ " Note: it requires 6000.0.23f1 or newer versions.";
#endif // UNITY_6000_0_23_OR_NEWER
private static readonly GUIContent _immersiveXRLabel = new GUIContent(
"Immersive XR", _immersiveXRTooltip);
private static readonly GUIContent _subsamplingLabel = new GUIContent(
"Subsampling (Vulkan)", _subsamplingTooltip);
private static readonly GUIContent _spacewarpLabel = new GUIContent(
"URP SpaceWarp (Vulkan)", _spacewarpTooltip);
private SerializedProperty _immersiveXR;
private SerializedProperty _subsampling;
private SerializedProperty _spacewarp;
/// <inheritdoc/>
public override void OnInspectorGUI()
{
EditorGUIUtility.labelWidth = 200.0f;
serializedObject.Update();
_immersiveXR.boolValue = EditorGUILayout.Toggle(
_immersiveXRLabel, _immersiveXR.boolValue);
_subsampling.boolValue = EditorGUILayout.Toggle(
_subsamplingLabel, _subsampling.boolValue);
_spacewarp.boolValue = EditorGUILayout.Toggle(_spacewarpLabel, _spacewarp.boolValue);
#if !UNITY_6000_0_23_OR_NEWER
if (_spacewarp.boolValue)
{
EditorGUILayout.HelpBox(
"URP Spacewarp (Vulkan) requires 6000.0.23f1 or newer versions.",
MessageType.Warning);
}
#endif
serializedObject.ApplyModifiedProperties();
EditorGUIUtility.labelWidth = 0f;
}
private void OnEnable()
{
_immersiveXR = serializedObject.FindProperty(_immersiveXRFieldName);
_subsampling = serializedObject.FindProperty(_subsamplingFieldName);
_spacewarp = serializedObject.FindProperty(_spacewarpFieldName);
}
}
}