AROcclusionManagerEditor.cs
3.25 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
using UnityEngine;
using UnityEngine.XR.ARFoundation;
using UnityEngine.XR.ARSubsystems;
namespace UnityEditor.XR.ARFoundation
{
[CustomEditor(typeof(AROcclusionManager))]
class AROcclusionManagerEditor : Editor
{
SerializedProperty m_EnvironmentDepthMode;
SerializedProperty m_OcclusionPreferenceMode;
SerializedProperty m_HumanSegmentationStencilMode;
SerializedProperty m_HumanSegmentationDepthMode;
public override void OnInspectorGUI()
{
serializedObject.Update();
bool isEnvDepthEnabled = ((EnvironmentDepthMode)m_EnvironmentDepthMode.enumValueIndex).Enabled();
bool isHumanSegmentationStencilEnabled = ((HumanSegmentationStencilMode)m_HumanSegmentationStencilMode.enumValueIndex).Enabled();
bool isHumanSegmentationDepthEnabled = ((HumanSegmentationDepthMode)m_HumanSegmentationDepthMode.enumValueIndex).Enabled();
bool isHumanDepthEnabled = isHumanSegmentationStencilEnabled && isHumanSegmentationDepthEnabled;
if (!isEnvDepthEnabled && !isHumanDepthEnabled)
{
EditorGUILayout.HelpBox("Automatic occlusion is disabled.",
MessageType.Warning);
}
EditorGUILayout.LabelField("Environment Depth", EditorStyles.boldLabel);
using (new EditorGUI.IndentLevelScope(1))
{
EditorGUILayout.PropertyField(m_EnvironmentDepthMode);
}
EditorGUILayout.LabelField("Human Segmentation", EditorStyles.boldLabel);
using (new EditorGUI.IndentLevelScope(1))
{
EditorGUILayout.PropertyField(m_HumanSegmentationStencilMode);
if (!isHumanSegmentationDepthEnabled && isHumanSegmentationStencilEnabled)
{
using (new EditorGUI.IndentLevelScope(1))
{
EditorGUILayout.HelpBox($"Human occlusion also requires {m_HumanSegmentationDepthMode.displayName} to be enabled.",
MessageType.Warning);
}
}
EditorGUILayout.PropertyField(m_HumanSegmentationDepthMode);
if (!isHumanSegmentationStencilEnabled && isHumanSegmentationDepthEnabled)
{
using (new EditorGUI.IndentLevelScope(1))
{
EditorGUILayout.HelpBox($"Human occlusion also requires {m_HumanSegmentationStencilMode.displayName} to be enabled.",
MessageType.Warning);
}
}
}
EditorGUILayout.PropertyField(m_OcclusionPreferenceMode);
serializedObject.ApplyModifiedProperties();
}
void OnEnable()
{
m_EnvironmentDepthMode = serializedObject.FindProperty("m_EnvironmentDepthMode");
m_HumanSegmentationStencilMode = serializedObject.FindProperty("m_HumanSegmentationStencilMode");
m_HumanSegmentationDepthMode = serializedObject.FindProperty("m_HumanSegmentationDepthMode");
m_OcclusionPreferenceMode = serializedObject.FindProperty("m_OcclusionPreferenceMode");
}
}
}