コード例 #1
0
        internal static void GenericStruct(SerializedProperty property, params GUILayoutOption[] options)
        {
            float num  = 16f + 16f * (float)StructPropertyGUILayout.GetChildrenCount(property);
            Rect  rect = GUILayoutUtility.GetRect(EditorGUILayout.kLabelFloatMinW, EditorGUILayout.kLabelFloatMaxW, num, num, EditorStyles.layerMaskField, options);

            StructPropertyGUI.GenericStruct(rect, property);
        }
コード例 #2
0
 public override void OnInspectorGUI()
 {
     base.serializedObject.Update();
     EditorGUILayout.PropertyField(this.m_Mass, new GUILayoutOption[0]);
     EditorGUILayout.PropertyField(this.m_Radius, new GUILayoutOption[0]);
     EditorGUILayout.PropertyField(this.m_WheelDampingRate, new GUILayoutOption[0]);
     EditorGUILayout.PropertyField(this.m_SuspensionDistance, new GUILayoutOption[0]);
     EditorGUILayout.PropertyField(this.m_ForceAppPointDistance, new GUILayoutOption[0]);
     EditorGUILayout.Space();
     EditorGUILayout.PropertyField(this.m_Center, new GUILayoutOption[0]);
     EditorGUILayout.Space();
     StructPropertyGUILayout.GenericStruct(this.m_SuspensionSpring, new GUILayoutOption[0]);
     StructPropertyGUILayout.GenericStruct(this.m_ForwardFriction, new GUILayoutOption[0]);
     StructPropertyGUILayout.GenericStruct(this.m_SidewaysFriction, new GUILayoutOption[0]);
     base.serializedObject.ApplyModifiedProperties();
 }
コード例 #3
0
 public override void OnInspectorGUI()
 {
     this.serializedObject.Update();
     EditorGUILayout.PropertyField(this.m_Mass);
     EditorGUILayout.PropertyField(this.m_Radius);
     EditorGUILayout.PropertyField(this.m_WheelDampingRate);
     EditorGUILayout.PropertyField(this.m_SuspensionDistance);
     EditorGUILayout.PropertyField(this.m_ForceAppPointDistance);
     EditorGUILayout.Space();
     EditorGUILayout.PropertyField(this.m_Center);
     EditorGUILayout.Space();
     StructPropertyGUILayout.JointSpring(this.m_SuspensionSpring);
     StructPropertyGUILayout.WheelFrictionCurve(this.m_ForwardFriction);
     StructPropertyGUILayout.WheelFrictionCurve(this.m_SidewaysFriction);
     this.serializedObject.ApplyModifiedProperties();
 }
コード例 #4
0
        public override void OnInspectorGUI()
        {
            serializedObject.Update();

            ArticulationBody body       = (ArticulationBody)target;
            ArticulationBody parentBody = FindParentBody(body);

            EditorGUILayout.PropertyField(m_Mass);

            if (body.isRoot)
            {
                EditorGUILayout.PropertyField(m_Immovable);

                EditorGUILayout.HelpBox("This is the root body of the articulation.", MessageType.Info);
            }
            else
            {
                EditorGUILayout.PropertyField(m_ComputeParentAnchor);

                // Show anchor edit fields and set to joint if changed
                // The reason we have change checks here is because in AwakeFromLoad we won't overwrite anchors
                // If we were to do that, simulation would drift caused by anchors reset relative to current poses
                EditorGUI.BeginChangeCheck();
                EditorGUILayout.PropertyField(m_AnchorPosition);
                QuaternionAsEulerAnglesPropertyField("Anchor Rotation", m_AnchorRotation, body.anchorRotation);
                if (EditorGUI.EndChangeCheck())
                {
                    body.anchorPosition = m_AnchorPosition.vector3Value;
                    body.anchorRotation = m_AnchorRotation.quaternionValue;

                    if (m_ComputeParentAnchor.boolValue)
                    {
                        // setting child anchors in this mode will also change the parent ones
                        // lets fetch them back otherwise ApplyModifiedProperties overwrites them
                        m_ParentAnchorPosition.vector3Value    = body.parentAnchorPosition;
                        m_ParentAnchorRotation.quaternionValue = body.parentAnchorRotation;
                    }
                }

                // parent anchors
                if (!m_ComputeParentAnchor.boolValue)
                {
                    EditorGUI.BeginChangeCheck();
                    EditorGUILayout.PropertyField(m_ParentAnchorPosition);
                    QuaternionAsEulerAnglesPropertyField("Parent Anchor Rotation", m_ParentAnchorRotation, body.parentAnchorRotation);

                    if (EditorGUI.EndChangeCheck())
                    {
                        body.parentAnchorPosition = m_ParentAnchorPosition.vector3Value;
                        body.parentAnchorRotation = m_ParentAnchorRotation.quaternionValue;
                    }
                }

                if (GUILayout.Button("Snap anchor to closest contact"))
                {
                    Vector3 com = parentBody.centerOfMass;
                    Vector3 closestOnSurface = body.GetClosestPoint(com);
                    body.anchorPosition = body.transform.InverseTransformPoint(closestOnSurface);
                    body.anchorRotation = Quaternion.FromToRotation(Vector3.right, body.transform.InverseTransformDirection(com - closestOnSurface).normalized);
                }

                EditorGUILayout.PropertyField(m_ArticulationJointType);

                EditorGUILayout.PropertyField(m_LinearDamping);
                EditorGUILayout.PropertyField(m_AngularDamping);
                EditorGUILayout.PropertyField(m_JointFriction);

                switch (body.jointType)
                {
                case ArticulationJointType.FixedJoint:
                    break;

                case ArticulationJointType.PrismaticJoint:
                    // toggles
                    PrismaticJointAxisLockProperty(m_LinearX);
                    PrismaticJointAxisLockProperty(m_LinearY);
                    PrismaticJointAxisLockProperty(m_LinearZ);

                    EditorGUILayout.Space();
                    if (body.linearLockX != ArticulationDofLock.LockedMotion)
                    {
                        StructPropertyGUILayout.GenericStruct(m_XDrive);
                    }

                    if (body.linearLockY != ArticulationDofLock.LockedMotion)
                    {
                        StructPropertyGUILayout.GenericStruct(m_YDrive);
                    }

                    if (body.linearLockZ != ArticulationDofLock.LockedMotion)
                    {
                        StructPropertyGUILayout.GenericStruct(m_ZDrive);
                    }

                    break;

                case ArticulationJointType.RevoluteJoint:
                    EditorGUILayout.PropertyField(m_Twist);

                    EditorGUILayout.Space();
                    StructPropertyGUILayout.GenericStruct(m_XDrive);

                    break;

                case ArticulationJointType.SphericalJoint:
                    EditorGUILayout.PropertyField(m_SwingY);
                    EditorGUILayout.PropertyField(m_SwingZ);
                    EditorGUILayout.PropertyField(m_Twist);

                    EditorGUILayout.Space();

                    if (body.swingYLock != ArticulationDofLock.LockedMotion)
                    {
                        StructPropertyGUILayout.GenericStruct(m_YDrive);
                    }

                    if (body.swingZLock != ArticulationDofLock.LockedMotion)
                    {
                        StructPropertyGUILayout.GenericStruct(m_ZDrive);
                    }

                    if (body.twistLock != ArticulationDofLock.LockedMotion)
                    {
                        StructPropertyGUILayout.GenericStruct(m_XDrive);
                    }

                    break;
                }
            }

            serializedObject.ApplyModifiedProperties();
        }
コード例 #5
0
 internal static void JointSpring(SerializedProperty property, params GUILayoutOption[] options)
 {
     StructPropertyGUILayout.GenericStruct(property, options);
 }
コード例 #6
0
 internal static void WheelFrictionCurve(SerializedProperty property, params GUILayoutOption[] options)
 {
     StructPropertyGUILayout.GenericStruct(property, options);
 }