10using System.Collections;
11using System.Collections.Generic;
17 [CanEditMultipleObjects]
18 [CustomEditor(typeof(InteractionController),
true)]
22 checkParentedToManager();
23 checkWithinHandModelManager();
24 checkPrimaryHoverPoints();
26 base.OnInspectorGUI();
29 private void checkPrimaryHoverPoints() {
30 bool anyPrimaryHoverPoints =
false;
31 bool anyWithNoPrimaryHoverPoints =
false;
32 foreach (var singleTarget
in targets) {
33 anyPrimaryHoverPoints =
false;
34 foreach (var primaryHoverPoint
in singleTarget.primaryHoverPoints) {
35 if (primaryHoverPoint !=
null) {
36 anyPrimaryHoverPoints =
true;
41 if (singleTarget.intHand !=
null) {
42 for (
int i = 0; i < singleTarget.intHand.enabledPrimaryHoverFingertips.Length; i++) {
43 if (singleTarget.intHand.enabledPrimaryHoverFingertips[i]) {
44 anyPrimaryHoverPoints =
true;
50 if (!anyPrimaryHoverPoints) {
51 anyWithNoPrimaryHoverPoints =
true;
56 if (anyWithNoPrimaryHoverPoints) {
57 string message =
"No primary hover points found for this interaction controller. "
58 +
"This controller will never trigger primary hover for an object. "
59 +
"UI elements such as InteractionButton and InteractionSlider "
60 +
"will not be able to interact with this interaction controller.";
61 EditorGUILayout.HelpBox(message, MessageType.Warning);
65 private void checkParentedToManager() {
66 bool plural =
targets.Length > 1;
67 bool anyNotParentedToInteractionManager;
69 anyNotParentedToInteractionManager =
targets.Query()
70 .Any(c => c.GetComponentInParent<InteractionManager>() ==
null);
72 if (anyNotParentedToInteractionManager) {
75 message +=
"One of more currently selected controllers ";
78 message +=
"The currently selected controller ";
81 message +=
"is not the child of an Interaction Manager. Interaction Controllers "
82 +
"must be childed to an Interaction Manager in order to function.";
84 EditorGUILayout.HelpBox(message, MessageType.Warning);
88 private void checkWithinHandModelManager() {
89 bool plural =
targets.Length > 1;
90 bool anyWithinHandPool;
92 HandModelManager handModelManager = FindObjectOfType<HandModelManager>();
93 if (handModelManager ==
null)
return;
95 anyWithinHandPool =
targets.Query()
96 .Any(c => c.transform.parent == handModelManager.transform);
98 if (anyWithinHandPool) {
101 message +=
"One or more of the currently selected controllers ";
104 message +=
"The currently selected controller ";
107 message +=
"is inside a HandModelManager. Interaction controllers, such "
108 +
"as InteractionHands, are not HandModels and are not spawned by the "
109 +
"HandModelManager. InteractionHands and all Interaction controllers "
110 +
"should be childed to the Interaction Manager.";
112 EditorGUILayout.HelpBox(message, MessageType.Error);
override void OnInspectorGUI()