示例#1
0
    private void createAttachToSurfaceMoverBehaviorUI(MoverBehavior moverBehavior)
    {
        SurfaceMoverBehavior surfaceMover = moverBehavior as SurfaceMoverBehavior;

        if (surfaceMover != null)
        {
            //EditorGUI.BeginChangeCheck();
            //Vector3 positionOffset = EditorGUILayout.Vector3Field("Position Offset", surfaceMover.getPositionOffset());
            //if (EditorGUI.EndChangeCheck())
            //{
            //	Undo.RecordObject(surfaceMover, "Position Offset");
            //	EditorUtility.SetDirty(surfaceMover);
            //	surfaceMover.setPositionOffset(positionOffset);
            //}

            EditorGUILayout.LabelField("Surface Collision Checker Transform");
            EditorGUI.BeginChangeCheck();
            Transform surfaceCheckTransform = (Transform)EditorGUILayout.ObjectField(surfaceMover.getSurfaceCheckSourceTransform(), typeof(Transform), true);
            if (EditorGUI.EndChangeCheck())
            {
                Undo.RecordObject(surfaceMover, "Surface Collision Checker Transform");
                EditorUtility.SetDirty(surfaceMover);
                surfaceMover.setSurfaceCheckSourceTransform(surfaceCheckTransform);
            }

            if (surfaceCheckTransform)
            {
                EditorGUI.BeginChangeCheck();
                Vector3 rayCastDirection = EditorGUILayout.Vector3Field("Default RayCast Direction", surfaceMover.getDefaultRaycastDirection());
                if (EditorGUI.EndChangeCheck())
                {
                    Undo.RecordObject(surfaceMover, "Default RayCast Direction");
                    EditorUtility.SetDirty(surfaceMover);
                    surfaceMover.setDefaultRaycastDirection(rayCastDirection);
                }

                LayerMask surfaceLayerMask = InspectorHelper.convert32BitLayerMaskToTrimmedMask(surfaceMover.getSurfaceLayerMask());
                EditorGUI.BeginChangeCheck();
                surfaceLayerMask = EditorGUILayout.MaskField("Surface Layer Mask", surfaceLayerMask, UnityEditorInternal.InternalEditorUtility.layers);
                if (EditorGUI.EndChangeCheck())
                {
                    Undo.RecordObject(surfaceMover, "Surface Layer Mask");
                    EditorUtility.SetDirty(surfaceMover);

                    surfaceMover.setSurfaceLayerMask(InspectorHelper.convertTrimmedLayerMaskTo32BitMask(surfaceLayerMask));
                }
            }

            EditorGUI.BeginChangeCheck();
            float friction = EditorGUILayout.FloatField("Friction", surfaceMover.getFrictionValue());
            if (EditorGUI.EndChangeCheck())
            {
                Undo.RecordObject(surfaceMover, "Friction");
                EditorUtility.SetDirty(surfaceMover);
                surfaceMover.setFrictionValue(Mathf.Clamp01(friction));
            }
        }
    }
示例#2
0
    private void createRigidBodyForceMoverBehaviorUI(MoverBehavior moverBehavior)
    {
        RigidBodyForceMoverBehavior rigidBodyForceMover = moverBehavior as RigidBodyForceMoverBehavior;

        if (rigidBodyForceMover != null)
        {
            EditorGUI.BeginChangeCheck();
            Vector3 forceMagnitude = EditorGUILayout.Vector3Field("Force Magnitude", rigidBodyForceMover.getForceMagnitude());
            if (EditorGUI.EndChangeCheck())
            {
                Undo.RecordObject(rigidBodyForceMover, "Force Magnitude");
                EditorUtility.SetDirty(rigidBodyForceMover);
                rigidBodyForceMover.setForceMagnitude(forceMagnitude);
            }

            EditorGUI.BeginChangeCheck();
            float duration = EditorGUILayout.DelayedFloatField("Duration", rigidBodyForceMover.getDuration());
            if (EditorGUI.EndChangeCheck())
            {
                Undo.RecordObject(rigidBodyForceMover, "Duration");
                EditorUtility.SetDirty(rigidBodyForceMover);
                rigidBodyForceMover.setDuration(duration);
            }

            EditorGUILayout.LabelField("RigidBody");
            EditorGUI.BeginChangeCheck();
            Rigidbody rigidBody = (Rigidbody)EditorGUILayout.ObjectField(rigidBodyForceMover.getRigidBody(), typeof(Rigidbody), true);
            if (EditorGUI.EndChangeCheck())
            {
                Undo.RecordObject(rigidBodyForceMover, "RigidBody");
                EditorUtility.SetDirty(rigidBodyForceMover);
                rigidBodyForceMover.setRigidBody(rigidBody);
            }

            EditorGUI.BeginChangeCheck();
            bool isAdditiveForce = EditorGUILayout.Toggle("Is Additive Force", rigidBodyForceMover.getIsAdditiveForce());
            if (EditorGUI.EndChangeCheck())
            {
                Undo.RecordObject(rigidBodyForceMover, "Is Additive Force");
                EditorUtility.SetDirty(rigidBodyForceMover);
                rigidBodyForceMover.setIsAdditiveForce(isAdditiveForce);
            }

            EditorGUILayout.LabelField("Surface Collision Checker Transform");
            EditorGUI.BeginChangeCheck();
            Transform surfaceCheckTransform = (Transform)EditorGUILayout.ObjectField(rigidBodyForceMover.getSurfaceCheckSourceTransform(), typeof(Transform), true);
            if (EditorGUI.EndChangeCheck())
            {
                Undo.RecordObject(rigidBodyForceMover, "Surface Collision Checker Transform");
                EditorUtility.SetDirty(rigidBodyForceMover);
                rigidBodyForceMover.setSurfaceCheckSourceTransform(surfaceCheckTransform);
            }

            if (surfaceCheckTransform)
            {
                EditorGUI.BeginChangeCheck();
                float surfaceCheckRadius = EditorGUILayout.DelayedFloatField("Checker Radius", rigidBodyForceMover.getSurfaceCheckRadius());
                if (EditorGUI.EndChangeCheck())
                {
                    Undo.RecordObject(rigidBodyForceMover, "Checker Radius");
                    EditorUtility.SetDirty(rigidBodyForceMover);
                    rigidBodyForceMover.setSurfaceCheckRadius(surfaceCheckRadius);
                }

                LayerMask surfaceLayerMask = InspectorHelper.convert32BitLayerMaskToTrimmedMask(rigidBodyForceMover.getSurfaceLayerMask());
                EditorGUI.BeginChangeCheck();
                surfaceLayerMask = EditorGUILayout.MaskField("Surface Layer Mask", surfaceLayerMask, UnityEditorInternal.InternalEditorUtility.layers);
                if (EditorGUI.EndChangeCheck())
                {
                    Undo.RecordObject(rigidBodyForceMover, "Surface Layer Mask");
                    EditorUtility.SetDirty(rigidBodyForceMover);

                    rigidBodyForceMover.setSurfaceLayerMask(InspectorHelper.convertTrimmedLayerMaskTo32BitMask(surfaceLayerMask));
                }
            }
        }
    }