private void RenderCriteriaField()

in Assets/MRTK/Core/Inspectors/Profiles/MixedRealityInputActionRulesInspector.cs [224:372]


        private void RenderCriteriaField(MixedRealityInputAction action, SerializedProperty criteriaValue = null)
        {
            var isWideMode = EditorGUIUtility.wideMode;
            EditorGUIUtility.wideMode = true;
            if (action != MixedRealityInputAction.None)
            {
                switch (action.AxisConstraint)
                {
                    default:
                        EditorGUILayout.HelpBox("Base rule must have a valid axis constraint.", MessageType.Warning);
                        break;
                    case AxisType.Digital:
                        using (new EditorGUILayout.HorizontalScope())
                        {
                            EditorGUILayout.LabelField(CriteriaContent, GUILayout.Width(128));
                            EditorGUI.BeginChangeCheck();
                            var boolValue = EditorGUILayout.Toggle(GUIContent.none, criteriaValue?.boolValue ?? currentBoolCriteria, GUILayout.Width(64), GUILayout.ExpandWidth(true));

                            if (EditorGUI.EndChangeCheck())
                            {
                                if (criteriaValue != null)
                                {
                                    criteriaValue.boolValue = boolValue;
                                }
                                else
                                {
                                    currentBoolCriteria = boolValue;
                                }
                            }
                        }
                        break;
                    case AxisType.SingleAxis:
                        using (new EditorGUILayout.HorizontalScope())
                        {
                            EditorGUILayout.LabelField(CriteriaContent, GUILayout.Width(128));
                            EditorGUI.BeginChangeCheck();
                            var floatValue = EditorGUILayout.FloatField(GUIContent.none, criteriaValue?.floatValue ?? currentSingleAxisCriteria, GUILayout.Width(64), GUILayout.ExpandWidth(true));

                            if (EditorGUI.EndChangeCheck())
                            {
                                if (criteriaValue != null)
                                {
                                    criteriaValue.floatValue = floatValue;
                                }
                                else
                                {
                                    currentSingleAxisCriteria = floatValue;
                                }
                            }
                        }
                        break;
                    case AxisType.DualAxis:
                        EditorGUILayout.LabelField(CriteriaContent, GUILayout.Width(128));
                        using (new EditorGUI.IndentLevelScope())
                        {
                            EditorGUI.BeginChangeCheck();
                            var dualAxisValue = EditorGUILayout.Vector2Field("Position", criteriaValue?.vector2Value ?? currentDualAxisCriteria, GUILayout.Width(64), GUILayout.ExpandWidth(true));

                            if (EditorGUI.EndChangeCheck())
                            {
                                if (criteriaValue != null)
                                {
                                    criteriaValue.vector2Value = dualAxisValue;
                                }
                                else
                                {
                                    currentDualAxisCriteria = dualAxisValue;
                                }
                            }
                        }
                        break;
                    case AxisType.ThreeDofPosition:
                        EditorGUILayout.LabelField(CriteriaContent, GUILayout.Width(128));
                        using (new EditorGUI.IndentLevelScope())
                        {
                            EditorGUI.BeginChangeCheck();
                            var positionValue = EditorGUILayout.Vector3Field("Position", criteriaValue?.vector3Value ?? currentVectorCriteria, GUILayout.ExpandWidth(true));

                            if (EditorGUI.EndChangeCheck())
                            {
                                if (criteriaValue != null)
                                {
                                    criteriaValue.vector3Value = positionValue;
                                }
                                else
                                {
                                    currentVectorCriteria = positionValue;
                                }
                            }
                        }
                        break;
                    case AxisType.ThreeDofRotation:
                        EditorGUILayout.LabelField(CriteriaContent, GUILayout.Width(128));
                        using (new EditorGUI.IndentLevelScope())
                        {
                            EditorGUI.BeginChangeCheck();
                            var rotationValue = EditorGUILayout.Vector3Field("Rotation", criteriaValue?.quaternionValue.eulerAngles ?? currentQuaternionCriteria.eulerAngles, GUILayout.ExpandWidth(true));

                            if (EditorGUI.EndChangeCheck())
                            {
                                if (criteriaValue != null)
                                {
                                    criteriaValue.quaternionValue = Quaternion.Euler(rotationValue);
                                }
                                else
                                {
                                    currentQuaternionCriteria = Quaternion.Euler(rotationValue);
                                }
                            }
                        }
                        break;
                    case AxisType.SixDof:
                        EditorGUILayout.LabelField(CriteriaContent, GUILayout.Width(128));
                        using (new EditorGUI.IndentLevelScope())
                        {
                            var posePosition = currentPoseCriteria.Position;
                            var poseRotation = currentPoseCriteria.Rotation;

                            if (criteriaValue != null)
                            {
                                posePosition = criteriaValue.FindPropertyRelative("position").vector3Value;
                                poseRotation = criteriaValue.FindPropertyRelative("rotation").quaternionValue;
                            }

                            EditorGUI.BeginChangeCheck();
                            posePosition = EditorGUILayout.Vector3Field("Position", posePosition);

                            poseRotation.eulerAngles = EditorGUILayout.Vector3Field("Rotation", poseRotation.eulerAngles);

                            if (EditorGUI.EndChangeCheck())
                            {
                                if (criteriaValue != null)
                                {
                                    criteriaValue.FindPropertyRelative("position").vector3Value = posePosition;
                                    criteriaValue.FindPropertyRelative("rotation").quaternionValue = poseRotation;
                                }
                                else
                                {
                                    currentPoseCriteria.Position = posePosition;
                                    currentPoseCriteria.Rotation = poseRotation;
                                }
                            }
                        }
                        break;
                }

                EditorGUIUtility.wideMode = isWideMode;
            }
        }