Пример #1
0
        public override void OnInspectorGUI()
        {
            /**
             * Currently the only difference is that the connectedAnchor vector field is greyed out if autoConfigureConnectedAnchor is true
             */
            serializedObject.Update();
            SerializedProperty iterator = serializedObject.GetIterator();

            for (bool enterChildren = true; iterator.NextVisible(enterChildren); enterChildren = false)
            {
                switch (iterator.propertyPath)
                {
                case "m_AutoConfigureConnectedAnchor":
                    break;

                case "m_ConnectedAnchor":
                    GUIUtilities.DrawConnectedAnchorProperty(connectedAnchor, autoConfigureConnectedAnchor);
                    break;

                default:
                    EditorGUILayout.PropertyField(iterator, true, null);
                    break;
                }
            }
            serializedObject.ApplyModifiedProperties();
        }
Пример #2
0
        public override void OnInspectorGUI()
        {
            serializedObject.Update();

            DrawSerializedProperties("ConnectedBody", "Anchor", "Axis");

            GUIUtilities.DrawConnectedAnchorProperty(properties["ConnectedAnchor"], properties["AutoConfigureConnectedAnchor"]);

            EditorGUILayout.PropertyField(properties["SecondaryAxis"]);

            EditorGUILayout.LabelField("Linear Limit", EditorStyles.boldLabel);
            MultiPropertyField("Linear Motion", xyzStrings, properties["XMotion"], properties["YMotion"], properties["ZMotion"]);

            /**
             * Linear Limit
             */
            EditorGUI.indentLevel = 1;
            if (joint.xMotion != ConfigurableJointMotion.Limited && joint.yMotion != ConfigurableJointMotion.Limited && joint.zMotion != ConfigurableJointMotion.Limited)
            {
                EditorGUILayout.HelpBox("The following linear limits are only used when at least one axis of Linear Motion is set to Limited", MessageType.Info);
            }

            EditorGUI.BeginChangeCheck();
            SoftJointLimit       linearLimitSoftJointLimit = new SoftJointLimit();
            SoftJointLimitSpring linearLimitSpring         = new SoftJointLimitSpring();

            linearLimitSoftJointLimit.limit           = EditorGUILayout.FloatField("Displacement Limit", joint.linearLimit.limit);
            linearLimitSoftJointLimit.bounciness      = EditorGUILayout.FloatField("Bounciness", joint.linearLimit.bounciness);
            linearLimitSoftJointLimit.contactDistance = EditorGUILayout.FloatField("Contact Distance", joint.linearLimit.contactDistance);
            linearLimitSpring.spring = EditorGUILayout.FloatField("Spring Force", joint.linearLimitSpring.spring);
            linearLimitSpring.damper = EditorGUILayout.FloatField("Damper", joint.linearLimitSpring.damper);
            EditorGUI.indentLevel    = 0;
            if (EditorGUI.EndChangeCheck())
            {
                Undo.RecordObject(joint, "Inspector");
                joint.linearLimit       = linearLimitSoftJointLimit;
                joint.linearLimitSpring = linearLimitSpring;
            }

            EditorGUILayout.LabelField("Angular Limits", EditorStyles.boldLabel);

            MultiPropertyField("Angular Motion", xyzStrings, properties["AngularXMotion"], properties["AngularYMotion"], properties["AngularZMotion"]);

            /**
             * X-axis Angular Limit
             */
            EditorGUILayout.LabelField("Angular X Limit");
            EditorGUI.indentLevel = 1;
            GUIUtilities.MinMaxWithFloatFields("Angle", properties["LowAngularXLimit.limit"], properties["HighAngularXLimit.limit"], -180f, 180f, 3);
            // TODO: Does the max bounciness and contact distance values actually ever get used? Is the lower/high angular limit distinction only for the joint angle limit?
            GUIUtilities.MinMaxWithFloatFields("Bounciness", properties["LowAngularXLimit.bounciness"], properties["HighAngularXLimit.bounciness"], 0f, 1f, 10);
            MinMaxPropertyFieldsControl("Contact Distance", properties["LowAngularXLimit.contactDistance"], properties["HighAngularXLimit.contactDistance"]);
            EditorGUILayout.PropertyField(properties["AngularXLimitSpring.spring"], new GUIContent("Spring Force"));
            DrawSerializedProperties("AngularXLimitSpring.damper");
            EditorGUI.indentLevel = 0;

            /**
             * Y-axis Angular Limit
             */
            EditorGUILayout.LabelField("Angular Y Limit");
            EditorGUI.indentLevel = 1;
            GUIUtilities.MinMaxWithFloatFields("Angle", properties["AngularYLimit.limit"], properties["AngularYLimit.limit"], -180f, 180f, 3);
            GUIUtilities.MinMaxWithFloatFields("Bounciness", properties["AngularYLimit.bounciness"], properties["AngularYLimit.bounciness"], -180f, 180f, 3);
            MinMaxPropertyFieldsControl("Contact Distance", properties["AngularYLimit.contactDistance"], properties["AngularYLimit.contactDistance"]);
            EditorGUI.indentLevel = 0;

            EditorGUILayout.LabelField("Angular Z Limit");
            EditorGUI.indentLevel = 1;
            GUIUtilities.MinMaxWithFloatFields("Angle", properties["AngularZLimit.limit"], properties["AngularZLimit.limit"], -180f, 180f, 3);
            GUIUtilities.MinMaxWithFloatFields("Bounciness", properties["AngularZLimit.bounciness"], properties["AngularZLimit.bounciness"], -180f, 180f, 3);
            MinMaxPropertyFieldsControl("Contact Distance", properties["AngularZLimit.contactDistance"], properties["AngularZLimit.contactDistance"]);
            EditorGUI.indentLevel = 0;

            EditorGUILayout.LabelField("Angular YZ Spring");
            EditorGUI.indentLevel = 1;
            EditorGUILayout.PropertyField(properties["AngularYZLimitSpring.spring"], new GUIContent("Spring Force"));
            DrawSerializedProperties("AngularYZLimitSpring.damper");
            EditorGUI.indentLevel = 0;

            EditorGUILayout.LabelField("Positional Drive", EditorStyles.boldLabel);

            DrawSerializedProperties("TargetPosition", "TargetVelocity");
            PropertyFieldsWithoutFoldout("XDrive", "YDrive", "ZDrive");

            /**
             * Rotation Drive
             */
            EditorGUILayout.LabelField("Rotational Drive", EditorStyles.boldLabel);
            DrawSerializedProperties("TargetAngularVelocity");
            MultiPropertyField("Target Rotation", new string[] { "X", "Y", "Z", "W" },
                               properties["TargetRotation.x"], properties["TargetRotation.y"], properties["TargetRotation.z"], properties["TargetRotation.w"]);
            DrawSerializedProperties("RotationDriveMode");
            EditorGUI.indentLevel = 1;
            PropertyFieldsWithoutFoldout("AngularXDrive", "AngularYZDrive", "SlerpDrive");

            EditorGUI.indentLevel = 0;

            EditorGUILayout.LabelField("Miscellaneous", EditorStyles.boldLabel);

            DrawSerializedProperties("ProjectionMode", "ProjectionDistance", "ProjectionAngle", "ConfiguredInWorldSpace", "SwapBodies", "BreakForce", "BreakTorque", "EnableCollision", "EnablePreprocessing", "MassScale", "ConnectedMassScale");

            serializedObject.ApplyModifiedProperties();
        }
Пример #3
0
        public override void OnInspectorGUI()
        {
            serializedObject.Update();
            SerializedProperty iterator = serializedObject.GetIterator();

            for (bool enterChildren = true; iterator.NextVisible(enterChildren); enterChildren = false)
            {
                SubPropertyOperator subPropertyOperator;

                switch (iterator.propertyPath)
                {
                case "m_AutoConfigureConnectedAnchor":
                    break;

                case "m_ConnectedAnchor":
                    GUIUtilities.DrawConnectedAnchorProperty(connectedAnchor, autoConfigureConnectedAnchor);
                    break;

                case "m_UseSpring":
                    useSpring.boolValue = EditorGUILayout.Toggle("Spring", useSpring.boolValue);
                    break;

                case "m_Spring":
                    EditorGUI.indentLevel = 1;
                    subPropertyOperator   = new SubPropertyOperator(iterator);
                    while (subPropertyOperator.MoveNext())
                    {
                        switch (subPropertyOperator.iterator.propertyPath)
                        {
                        case "m_Spring.spring":
                            EditorGUILayout.PropertyField(subPropertyOperator.iterator, new GUIContent("Force"));
                            break;

                        default:
                            EditorGUILayout.PropertyField(subPropertyOperator.iterator);
                            break;
                        }
                    }
                    EditorGUI.indentLevel = 0;
                    break;

                case "m_UseMotor":
                    useMotor.boolValue = EditorGUILayout.Toggle("Motor", useMotor.boolValue);
                    break;

                case "m_Motor":
                    EditorGUI.indentLevel = 1;
                    GUIUtilities.PropertyFieldWithoutHeader(motor);
                    EditorGUI.indentLevel = 0;
                    break;

                case "m_UseLimits":
                    useLimits.boolValue = EditorGUILayout.Toggle("Limits", useLimits.boolValue);
                    break;

                case "m_Limits":
                    EditorGUI.indentLevel = 1;
                    subPropertyOperator   = new SubPropertyOperator(iterator);
                    while (subPropertyOperator.MoveNext())
                    {
                        EditorGUILayout.PropertyField(subPropertyOperator.iterator);

                        // Clamp the min and max limit properties only to -180 to 180
                        switch (subPropertyOperator.iterator.propertyPath)
                        {
                        case "m_Limits.min":
                        case "m_Limits.max":
                            subPropertyOperator.iterator.floatValue = Mathf.Clamp(subPropertyOperator.iterator.floatValue, -180f, 180f);
                            break;
                        }
                    }
                    EditorGUI.indentLevel = 0;
                    break;

                default:
                    EditorGUILayout.PropertyField(iterator, true, null);
                    break;
                }
            }
            serializedObject.ApplyModifiedProperties();
        }