コード例 #1
0
        public override void OnInspectorGUI()
        {
            if (target != null)
            {
                // Notification section - first thing to show in bounds control component
                DrawRigidBodyWarning();

                // Help url
                InspectorUIUtility.RenderHelpURL(target.GetType());

                // Data section
                {
                    EditorGUI.BeginChangeCheck();

                    EditorGUILayout.PropertyField(targetObject);

                    EditorGUILayout.Space();
                    EditorGUILayout.LabelField(new GUIContent("Behavior"), EditorStyles.boldLabel);
                    EditorGUILayout.PropertyField(activationType);
                    EditorGUILayout.PropertyField(boundsOverride);
                    EditorGUILayout.PropertyField(boundsCalculationMethod);
                    EditorGUILayout.PropertyField(controlPadding);
                    EditorGUILayout.PropertyField(flattenAxis);
                    EditorGUILayout.PropertyField(uniformScaleOnFlattenedAxis);

                    EditorGUILayout.Space();
                    EditorGUILayout.LabelField(new GUIContent("Smoothing"), EditorStyles.boldLabel);
                    EditorGUILayout.PropertyField(smoothingActive);
                    EditorGUILayout.PropertyField(scaleLerpTime);
                    EditorGUILayout.PropertyField(rotateLerpTime);

                    EditorGUILayout.Space();
                    EditorGUILayout.LabelField(new GUIContent("Visuals", "Bounds Control Visual Configurations"), EditorStyles.boldLabel, GUILayout.ExpandWidth(true));
                    using (new EditorGUI.IndentLevelScope())
                    {
                        showBoxConfiguration = InspectorUIUtility.DrawScriptableFoldout <BoxDisplayConfiguration>(boxDisplayConfiguration,
                                                                                                                  "Box Configuration",
                                                                                                                  showBoxConfiguration);

                        showScaleHandlesConfiguration = InspectorUIUtility.DrawScriptableFoldout <ScaleHandlesConfiguration>(scaleHandlesConfiguration,
                                                                                                                             "Scale Handles Configuration",
                                                                                                                             showScaleHandlesConfiguration);

                        showRotationHandlesConfiguration = InspectorUIUtility.DrawScriptableFoldout <RotationHandlesConfiguration>(rotationHandlesConfiguration,
                                                                                                                                   "Rotation Handles Configuration",
                                                                                                                                   showRotationHandlesConfiguration);

                        showTranslationHandlesConfiguration = InspectorUIUtility.DrawScriptableFoldout <TranslationHandlesConfiguration>(translationHandlesConfiguration,
                                                                                                                                         "Translation Handles Configuration",
                                                                                                                                         showTranslationHandlesConfiguration);

                        showLinksConfiguration = InspectorUIUtility.DrawScriptableFoldout <LinksConfiguration>(linksConfiguration,
                                                                                                               "Links Configuration",
                                                                                                               showLinksConfiguration);

                        showProximityConfiguration = InspectorUIUtility.DrawScriptableFoldout <ProximityEffectConfiguration>(proximityEffectConfiguration,
                                                                                                                             "Proximity Configuration",
                                                                                                                             showProximityConfiguration);
                    }

                    EditorGUILayout.Space();

                    constraintsFoldout = ConstraintManagerInspector.DrawConstraintManagerFoldout(boundsControl.gameObject,
                                                                                                 enableConstraints,
                                                                                                 constraintManager,
                                                                                                 constraintsFoldout);

                    EditorGUILayout.Space();
                    EditorGUILayout.LabelField(new GUIContent("Events", "Bounds Control Events"), EditorStyles.boldLabel, GUILayout.ExpandWidth(true));
                    {
                        EditorGUILayout.PropertyField(rotateStartedEvent);
                        EditorGUILayout.PropertyField(rotateStoppedEvent);
                        EditorGUILayout.PropertyField(scaleStartedEvent);
                        EditorGUILayout.PropertyField(scaleStoppedEvent);
                        EditorGUILayout.PropertyField(translateStartedEvent);
                        EditorGUILayout.PropertyField(translateStoppedEvent);
                    }

                    EditorGUILayout.Space();

                    ElasticsManagerInspector.DrawElasticsManagerLink(elasticsManager, boundsControl.gameObject);

                    EditorGUILayout.Space();
                    EditorGUILayout.LabelField(new GUIContent("Debug", "Bounds Control Debug Section"), EditorStyles.boldLabel, GUILayout.ExpandWidth(true));
                    {
                        EditorGUILayout.PropertyField(hideElementsInHierarchyEditor);
                    }

                    if (EditorGUI.EndChangeCheck())
                    {
                        serializedObject.ApplyModifiedProperties();
                    }
                }
            }
        }
        public override void OnInspectorGUI()
        {
            EditorGUILayout.PropertyField(hostTransform);
            EditorGUILayout.PropertyField(manipulationType);
            EditorGUILayout.PropertyField(allowFarManipulation);

            // Near Interaction Support foldout
            nearInteractionFoldout = EditorGUILayout.Foldout(nearInteractionFoldout, "Near Interaction Support", true);

            if (nearInteractionFoldout)
            {
                if (instance.GetComponent <NearInteractionGrabbable>() == null)
                {
                    EditorGUILayout.HelpBox($"By default, {nameof(ObjectManipulator)} only responds to far interaction input.  Add a {nameof(NearInteractionGrabbable)} component to enable near interaction support.", MessageType.Warning);

                    if (GUILayout.Button("Add Near Interaction Grabbable"))
                    {
                        instance.gameObject.AddComponent <NearInteractionGrabbable>();
                    }
                }
                else
                {
                    EditorGUILayout.HelpBox($"A {nameof(NearInteractionGrabbable)} is attached to this object, near interaction support is enabled.", MessageType.Info);
                }
            }

            var handedness = (ManipulationHandFlags)manipulationType.intValue;

            EditorGUILayout.Space();
            GUIStyle  style         = EditorStyles.foldout;
            FontStyle previousStyle = style.fontStyle;

            style.fontStyle  = FontStyle.Bold;
            oneHandedFoldout = EditorGUILayout.Foldout(oneHandedFoldout, "One Handed Manipulation", true);

            if (oneHandedFoldout)
            {
                if (handedness.IsMaskSet(ManipulationHandFlags.OneHanded))
                {
                    EditorGUILayout.PropertyField(oneHandRotationModeNear);
                    EditorGUILayout.PropertyField(oneHandRotationModeFar);
                }
                else
                {
                    EditorGUILayout.HelpBox("One handed manipulation disabled. If you wish to enable one handed manipulation select it as a Manipulation Type above.", MessageType.Info);
                }
            }

            EditorGUILayout.Space();
            twoHandedFoldout = EditorGUILayout.Foldout(twoHandedFoldout, "Two Handed Manipulation", true);

            if (twoHandedFoldout)
            {
                if (handedness.IsMaskSet(ManipulationHandFlags.TwoHanded))
                {
                    EditorGUILayout.PropertyField(twoHandedManipulationType);
                }
                else
                {
                    EditorGUILayout.HelpBox("Two handed manipulation disabled. If you wish to enable two handed manipulation select it as a Manipulation Type above.", MessageType.Info);
                }
            }

            var mh = (ObjectManipulator)target;
            var rb = mh.HostTransform.GetComponent <Rigidbody>();

            EditorGUILayout.Space();

            constraintsFoldout = ConstraintManagerInspector.DrawConstraintManagerFoldout(mh.gameObject,
                                                                                         enableConstraints,
                                                                                         constraintManager,
                                                                                         constraintsFoldout);

            EditorGUILayout.Space();
            physicsFoldout = EditorGUILayout.Foldout(physicsFoldout, "Physics", true);

            if (physicsFoldout)
            {
                if (rb != null)
                {
                    EditorGUILayout.PropertyField(releaseBehavior);
                    EditorGUILayout.PropertyField(useForcesForNearManipulation);
                }
                else
                {
                    EditorGUILayout.HelpBox("Physics options disabled. If you wish to enable physics options, add a Rigidbody component to this object.", MessageType.Info);
                }
            }

            EditorGUILayout.Space();
            smoothingFoldout = EditorGUILayout.Foldout(smoothingFoldout, "Smoothing", true);

            if (smoothingFoldout)
            {
                EditorGUILayout.PropertyField(transformSmoothingLogicType);
                EditorGUILayout.PropertyField(smoothingFar);
                EditorGUILayout.PropertyField(smoothingNear);
                EditorGUILayout.PropertyField(moveLerpTime);
                EditorGUILayout.PropertyField(rotateLerpTime);
                EditorGUILayout.PropertyField(scaleLerpTime);
            }

            EditorGUILayout.Space();
            eventsFoldout = EditorGUILayout.Foldout(eventsFoldout, "Manipulation Events", true);

            if (eventsFoldout)
            {
                EditorGUILayout.PropertyField(onManipulationStarted);
                EditorGUILayout.PropertyField(onManipulationEnded);
                EditorGUILayout.PropertyField(onHoverEntered);
                EditorGUILayout.PropertyField(onHoverExited);
            }

            EditorGUILayout.Space();

            Microsoft.MixedReality.Toolkit.Experimental.Editor.ElasticsManagerInspector.DrawElasticsManagerLink(elasticsManager, mh.gameObject);

            EditorGUILayout.Space();

            // reset foldouts style
            style.fontStyle = previousStyle;

            serializedObject.ApplyModifiedProperties();
        }
コード例 #3
0
        public override void OnInspectorGUI()
        {
            if (target != null)
            {
                // Notification section - first thing to show in bounds control component
                DrawRigidBodyWarning();

                // Help url
                InspectorUIUtility.RenderHelpURL(target.GetType());

                // Data section
                {
                    EditorGUI.BeginChangeCheck();

                    // Initializes the target object of the bounds control to itself
                    EditorGUILayout.PropertyField(targetObject);
                    if (targetObject.objectReferenceValue == null)
                    {
                        targetObject.objectReferenceValue = boundsControl.gameObject;
                    }

                    // Checks that the targetObject has a box collider that this bounds control can manage if bounds override was not supplied, otherwise, raises a warning and prompts the user to add one
                    if (boundsOverride.objectReferenceValue == null)
                    {
                        GameObject boundsTargetObject = targetObject.objectReferenceValue as GameObject;
                        if (boundsTargetObject != null && boundsTargetObject.GetComponent <BoxCollider>() == null)
                        {
                            EditorGUILayout.HelpBox("No Box Collider assigned to the TargetObject and no Bounds Override assigned, add a Box Collider to enable proper interaction with the Bounds Control", MessageType.Warning);

                            if (GUILayout.Button("Add Box Collider to Target Object"))
                            {
                                boundsTargetObject.AddComponent <BoxCollider>();
                            }
                        }
                    }

                    EditorGUILayout.Space();
                    EditorGUILayout.LabelField(new GUIContent("Behavior"), EditorStyles.boldLabel);
                    EditorGUILayout.PropertyField(activationType);
                    EditorGUILayout.PropertyField(boundsOverride);

                    EditorGUILayout.PropertyField(boundsCalculationMethod);
                    EditorGUILayout.PropertyField(controlPadding);
                    EditorGUILayout.PropertyField(flattenAxis);
                    EditorGUILayout.PropertyField(uniformScaleOnFlattenedAxis);

                    EditorGUILayout.Space();
                    EditorGUILayout.LabelField(new GUIContent("Smoothing"), EditorStyles.boldLabel);
                    EditorGUILayout.PropertyField(smoothingActive);
                    EditorGUILayout.PropertyField(scaleLerpTime);
                    EditorGUILayout.PropertyField(rotateLerpTime);

                    EditorGUILayout.Space();
                    EditorGUILayout.LabelField(new GUIContent("Visuals", "Bounds Control Visual Configurations"), EditorStyles.boldLabel, GUILayout.ExpandWidth(true));
                    using (new EditorGUI.IndentLevelScope())
                    {
                        showBoxConfiguration = InspectorUIUtility.DrawScriptableFoldout <BoxDisplayConfiguration>(boxDisplayConfiguration,
                                                                                                                  "Box Configuration",
                                                                                                                  showBoxConfiguration);

                        showScaleHandlesConfiguration = InspectorUIUtility.DrawScriptableFoldout <ScaleHandlesConfiguration>(scaleHandlesConfiguration,
                                                                                                                             "Scale Handles Configuration",
                                                                                                                             showScaleHandlesConfiguration);

                        showRotationHandlesConfiguration = InspectorUIUtility.DrawScriptableFoldout <RotationHandlesConfiguration>(rotationHandlesConfiguration,
                                                                                                                                   "Rotation Handles Configuration",
                                                                                                                                   showRotationHandlesConfiguration);

                        showTranslationHandlesConfiguration = InspectorUIUtility.DrawScriptableFoldout <TranslationHandlesConfiguration>(translationHandlesConfiguration,
                                                                                                                                         "Translation Handles Configuration",
                                                                                                                                         showTranslationHandlesConfiguration);

                        showLinksConfiguration = InspectorUIUtility.DrawScriptableFoldout <LinksConfiguration>(linksConfiguration,
                                                                                                               "Links Configuration",
                                                                                                               showLinksConfiguration);

                        showProximityConfiguration = InspectorUIUtility.DrawScriptableFoldout <ProximityEffectConfiguration>(proximityEffectConfiguration,
                                                                                                                             "Proximity Configuration",
                                                                                                                             showProximityConfiguration);
                    }

                    EditorGUILayout.Space();

                    constraintsFoldout = ConstraintManagerInspector.DrawConstraintManagerFoldout(boundsControl.gameObject,
                                                                                                 enableConstraints,
                                                                                                 constraintManager,
                                                                                                 constraintsFoldout);

                    EditorGUILayout.Space();
                    EditorGUILayout.LabelField(new GUIContent("Events", "Bounds Control Events"), EditorStyles.boldLabel, GUILayout.ExpandWidth(true));
                    {
                        EditorGUILayout.PropertyField(rotateStartedEvent);
                        EditorGUILayout.PropertyField(rotateStoppedEvent);
                        EditorGUILayout.PropertyField(scaleStartedEvent);
                        EditorGUILayout.PropertyField(scaleStoppedEvent);
                        EditorGUILayout.PropertyField(translateStartedEvent);
                        EditorGUILayout.PropertyField(translateStoppedEvent);
                    }

                    EditorGUILayout.Space();

                    ElasticsManagerInspector.DrawElasticsManagerLink(elasticsManager, boundsControl.gameObject);

                    EditorGUILayout.Space();
                    EditorGUILayout.LabelField(new GUIContent("Debug", "Bounds Control Debug Section"), EditorStyles.boldLabel, GUILayout.ExpandWidth(true));
                    {
                        EditorGUILayout.PropertyField(hideElementsInHierarchyEditor);
                    }

                    if (EditorGUI.EndChangeCheck())
                    {
                        serializedObject.ApplyModifiedProperties();
                    }
                }
            }
        }