15 [CanEditMultipleObjects]
16 [CustomEditor(typeof(InteractionBehaviour), editorForChildClasses:
true)]
35 "_moveObjectWhenGrasped",
36 "graspedMovementType");
47 private void drawInteractionManagerDecorator(SerializedProperty property) {
48 bool shouldDrawInteractionManagerNotSetWarning =
false;
50 if (Utils.IsObjectPartOfPrefabAsset(
target))
continue;
52 if (
target.manager ==
null) {
53 shouldDrawInteractionManagerNotSetWarning =
true;
57 if (shouldDrawInteractionManagerNotSetWarning) {
58 bool pluralTargets =
targets.Length > 1;
59 string noManagerSetWarningMessage =
"";
61 noManagerSetWarningMessage =
"One or more of the currently selected interaction "
62 +
"objects doesn't have its Interaction Manager set. ";
65 noManagerSetWarningMessage =
"The currently selected interaction object doesn't "
66 +
"have its Interaction Manager set. ";
68 noManagerSetWarningMessage +=
" Object validation requires a configured manager "
71 drawSetManagerWarningBox(noManagerSetWarningMessage, MessageType.Error);
75 private void drawSetManagerWarningBox(
string warningMessage, MessageType messageType) {
76 EditorGUILayout.BeginHorizontal();
78 EditorGUILayout.HelpBox(warningMessage, messageType);
80 Rect buttonRect = EditorGUILayout.GetControlRect(GUILayout.MaxWidth(100F),
81 GUILayout.ExpandHeight(
true),
82 GUILayout.MaxHeight(40F));
83 InteractionManager manager = InteractionManager.instance;
84 EditorGUI.BeginDisabledGroup(manager ==
null);
85 if (GUI.Button(buttonRect,
new GUIContent(
"Auto-Fix",
86 manager ==
null ?
"Please add an Interaction Manager to "
88 :
"Use InteractionManager.instance to "
89 +
"automatically set the manager of the "
90 +
"selected interaction objects."))) {
91 if (manager ==
null) {
92 Debug.LogError(
"Attempt to find an InteractionManager instance failed. Is there "
93 +
"an InteractionManager in your scene?");
97 if (Utils.IsObjectPartOfPrefabAsset(
target))
continue;
99 Undo.RecordObject(
target,
"Auto-set Interaction Manager");
104 EditorGUI.EndDisabledGroup();
106 EditorGUILayout.EndHorizontal();
108 EditorGUILayout.Space();
111 private void drawInteractionLayerDecorator(SerializedProperty property) {
112 bool shouldDrawWarning =
false;
114 if (
target.manager ==
null)
continue;
116 if (
target.overrideInteractionLayer
117 && !
target.manager.autoGenerateLayers
118 &&
Physics.GetIgnoreLayerCollision(
target.interactionLayer.layerIndex,
119 target.manager.contactBoneLayer.layerIndex)) {
121 shouldDrawWarning =
true;
126 if (shouldDrawWarning) {
127 bool pluralTargets =
targets.Length > 1;
130 message =
"One or more of the selected interaction objects has its "
131 +
"Interaction layer set NOT to collide with the contact bone "
135 message =
"The selected interaction object has its Interaction layer set "
136 +
"NOT to collide with the contact bone layer. ";
138 message +=
"This will prevent an interaction object from supporting contact with "
139 +
"any hands or controllers.";
141 EditorGUILayout.HelpBox(message, MessageType.Warning);
145 private void drawNoContactLayerDecorator(SerializedProperty property) {
146 bool shouldDrawCollisionWarning =
false;
148 if (
target.manager ==
null)
continue;
150 if (
target.overrideNoContactLayer
151 && !
target.manager.autoGenerateLayers
152 && !
Physics.GetIgnoreLayerCollision(
target.noContactLayer.layerIndex,
153 target.manager.contactBoneLayer.layerIndex)) {
154 shouldDrawCollisionWarning =
true;
159 if (shouldDrawCollisionWarning) {
160 bool pluralTargets =
targets.Length > 1;
161 string noContactErrorMessage;
163 noContactErrorMessage =
"One or more selected interaction objects has its No "
164 +
"Contact layer set to collide with the contact bone "
168 noContactErrorMessage =
"This interaction object has its No Contact layer set "
169 +
"to collide with the contact bone layer. ";
172 noContactErrorMessage +=
"Please ensure the Interaction Manager's contact bone "
173 +
"layer is set not to collide with any interaction "
174 +
"object's No Contact layer.";
176 EditorGUILayout.HelpBox(noContactErrorMessage, MessageType.Error);
183 base.OnInspectorGUI();
186 private void checkHasColliders() {
187 bool anyMissingColliders =
false;
188 foreach (var singleTarget
in targets) {
189 if (singleTarget.GetComponentsInChildren<Collider>().Length == 0) {
190 anyMissingColliders =
true;
break;
194 if (anyMissingColliders) {
195 bool pluralObjects =
targets.Length > 1;
199 message =
"One or more of the currently selected interaction objects have no "
200 +
"colliders. Interaction objects without any Colliders cannot be "
201 +
"interacted with.";
204 message =
"This interaction object has no Colliders. Interaction objects "
205 +
"without any Colliders cannot be interacted with.";
208 EditorGUILayout.HelpBox(message, MessageType.Warning);
212 private void drawEventTable(SerializedProperty property) {
213 if (_tableEditor ==
null) {
214 _tableEditor =
new EnumEventTableEditor(property, typeof(InteractionBehaviour.EventType));
void specifyConditionalDrawing(string conditionalName, params string[] dependantProperties)
Specify a list of properties that should only be displayed if the conditional property has a value of...
void deferProperty(string propertyName)
Defer rendering of a property until the end of the inspector. Deferred properties are drawn in the RE...
void specifyCustomDrawer(string propertyName, Action< SerializedProperty > propertyDrawer)
Specify a callback to be used to draw a specific named property. Should be called in OnEnable.
void specifyCustomDecorator(string propertyName, Action< SerializedProperty > decoratorDrawer)
Specify a callback to be used to draw a decorator for a specific named property. Should be called in ...
override void OnInspectorGUI()