11using System.Collections;
12using System.Collections.Generic;
18 [CanEditMultipleObjects]
19 [CustomEditor(typeof(InteractionXRController),
true)]
22 private List<InteractionXRController> _vrControllers;
24 bool _pluralPossibleControllers =
false;
30 _vrControllers =
targets.Query()
34 _pluralPossibleControllers = _vrControllers.Count > 1;
39 private void drawGraspButtonAxisDecorator(SerializedProperty property) {
41 int numGraspAxisOverrides = _vrControllers.Query()
42 .Where(c => c.graspAxisOverride !=
null)
44 bool anyGraspAxisOverrides = numGraspAxisOverrides > 0;
46 if (anyGraspAxisOverrides) {
47 string graspAxisOverrideMessage;
48 if (_pluralPossibleControllers) {
49 graspAxisOverrideMessage =
"One or more currently selected interaction VR "
50 +
"controllers has their grasping axis overridden, "
51 +
"so their graspButtonAxis settings will be ignored.";
54 graspAxisOverrideMessage =
"This interaction VR controller has its grasping "
55 +
"axis overridden, so the graspButtonAxis setting "
58 EditorGUILayout.HelpBox(graspAxisOverrideMessage, MessageType.Info);
62 bool anyInvalidGraspAxes = _vrControllers.Query()
63 .Select(c => isGraspAxisConfigured(c))
64 .Where(b => b ==
false)
67 if (anyInvalidGraspAxes) {
68 string graspAxisInvalidMessage;
69 if (_pluralPossibleControllers) {
70 graspAxisInvalidMessage =
"One or more currently selected interaction VR "
71 +
"controllers is configured with a grasping axis name "
72 +
"that is not set up in Unity's Input settings.";
75 graspAxisInvalidMessage =
"This interaction VR controller is configured with a "
76 +
"grasping axis name that is not set up in Unity's "
79 graspAxisInvalidMessage +=
" Check your input settings via Edit -> Project "
80 +
"Settings -> Input. Otherwise, this interaction "
81 +
"controller will be unable to grasp objects.";
83 EditorGUILayout.HelpBox(graspAxisInvalidMessage, MessageType.Warning);
87 private bool isGraspAxisConfigured(InteractionXRController controller) {
89 Input.GetAxis(controller.graspButtonAxis);
92 catch (ArgumentException) {
void specifyCustomPostDecorator(string propertyName, Action< SerializedProperty > decoratorDrawer)
Specify a callback to be used to draw a decorator AFTER a specific named property.