private bool DrawElasticConfiguration <T>(
     string name,
     bool expanded,
     SerializedProperty elasticProperty,
     SerializedProperty extentProperty,
     TransformFlags requiredFlag,
     TransformFlags providedFlags) where T : ElasticConfiguration
 {
     if (providedFlags.HasFlag(requiredFlag))
     {
         bool result = false;
         using (new EditorGUI.IndentLevelScope())
         {
             result = InspectorUIUtility.DrawScriptableFoldout <T>(
                 elasticProperty,
                 name,
                 expanded);
             EditorGUILayout.PropertyField(extentProperty, includeChildren: true);
         }
         return(result);
     }
     else
     {
         return(false);
     }
 }
Beispiel #2
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.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 = InspectorUIUtility.DrawComponentTypeFoldout <TransformConstraint>(boundsControl.gameObject, constraintsFoldout, "Constraint");

                    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();
                    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()
        {
            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();
                    }
                }
            }
        }