Ejemplo n.º 1
0
        public override void OnInspectorGUI()
        {
            serializedObject.Update();

            //Color GUIBlue = new Color32(82, 140, 255, 255);

            EditorHelpers.DrawLogoAndVersion();

            //BSoftBody sb = (BSoftBody)target;
            //sb.m_collisionFlags = BCollisionObjectEditor.RenderEnumMaskCollisionFlagsField(BCollisionObjectEditor.gcCollisionFlags, sb.m_collisionFlags);
            //sb.m_groupsIBelongTo = BCollisionObjectEditor.RenderEnumMaskCollisionFilterGroupsField(BCollisionObjectEditor.gcGroupsIBelongTo, sb.m_groupsIBelongTo);
            //sb.m_collisionMask = BCollisionObjectEditor.RenderEnumMaskCollisionFilterGroupsField(BCollisionObjectEditor.gcCollisionMask, sb.m_collisionMask);

            if (bSoftBodyTarget is BSoftBodyWMesh)
            {
                DrawCustomMeshSettingsOptions();
            }

            DrawPropertiesExcluding(serializedObject, hideMe); //Draw settings after the default inspector
            //DrawDefaultInspector();//Items custom to this type of SoftBody

            EditorGUILayout.BeginHorizontal();
            if (EditorHelpers.InspectorButton("Apply Preset", 100, 15, GUIBlue))
            {
                //SBSettingsPresets saveMe = bSoftBodyTarget.SoftBodySettings.sBpresetSelect;
                bSoftBodyTarget.SoftBodySettings.ResetToSoftBodyPresets(bSoftBodyTarget.SoftBodySettings.sBpresetSelect);
                //bSoftBodyTarget.SoftBodySettings.sBpresetSelect = saveMe;
            }

            bSoftBodyTarget.SoftBodySettings.sBpresetSelect = (SBSettingsPresets)EditorGUILayout.EnumPopup(bSoftBodyTarget.SoftBodySettings.sBpresetSelect);

            EditorGUILayout.EndHorizontal();
            EditorGUILayout.Space();

            //bitmask field for collisions
            bSoftBodyTarget.SoftBodySettings.config.Collisions = (BulletSharp.SoftBody.CollisionFlags)EditorGUILayout.EnumMaskField(gcCollisionTooltip, bSoftBodyTarget.SoftBodySettings.config.Collisions);

            EditorGUILayout.PropertyField(softBodySettings, gcSoftBodySettings, true);

            serializedObject.ApplyModifiedProperties();

            if (GUI.changed) //Can apply settings on editor change
            {
                bSoftBodyTarget.BuildSoftBody();
            }
        }
Ejemplo n.º 2
0
 [MenuItem("GameObject/Create Other/BulletForUnity/BSoftBody/Rope")]  //right click menu
 static void CreateBCube()
 {
     Selection.activeObject = BSoftBodyRope.CreateNew(EditorHelpers.GetCameraRaycastPosition(), Quaternion.identity);
     PostCreateObject();
 }
Ejemplo n.º 3
0
 [MenuItem("GameObject/Create Other/BulletForUnity/BSoftBody/BSoftBodyWMesh")]  //right click menu
 static void CreateBSoftWithMesh()
 {
     Selection.activeObject = BSoftBodyWMesh.CreateNew(EditorHelpers.GetCameraRaycastPosition(), Quaternion.identity, BAnyMeshSettingsForEditor.Instance.Build(), true);
     PostCreateObject();
 }
Ejemplo n.º 4
0
        //Hackish method to get past Unity serialization
        void DrawCustomMeshSettingsOptions()
        {
            EditorGUILayout.TextArea("Generate Custom Mesh?");

            //Get Instance
            BAnyMeshSettingsForEditor bAny = BAnyMeshSettingsForEditor.Instance;

            //Build it!
            if (EditorHelpers.InspectorButton("Update Mesh", 100, 15, GUIBlue, "New/Change mesh"))
            {
                ((BSoftBodyWMesh)bSoftBodyTarget).meshSettings.UserMesh = bAny.Build();
                bSoftBodyTarget.BuildSoftBody();
            }

            bAny.imediateUpdate = EditorGUILayout.Toggle("Imediate Update", bAny.imediateUpdate);

            //Select a mesh type
            bAny.meshType = (PrimitiveMeshOptions)EditorGUILayout.EnumPopup("Mesh Type", bAny.meshType);

            switch (bAny.meshType)
            {
            case PrimitiveMeshOptions.UserDefinedMesh:

                break;

            case PrimitiveMeshOptions.Box:
                bAny.extents = EditorGUILayout.Vector3Field("Extents", bAny.extents);
                break;

            case PrimitiveMeshOptions.Sphere:
                bAny.radius            = EditorGUILayout.FloatField("radius", bAny.radius);
                bAny.numLongitudeLines = EditorGUILayout.IntField("numLongitudeLines", bAny.numLongitudeLines);
                bAny.numLatitudeLines  = EditorGUILayout.IntField("numLatitudeLines", bAny.numLatitudeLines);

                break;

            case PrimitiveMeshOptions.Cylinder:
                bAny.height  = EditorGUILayout.FloatField("height", bAny.height);
                bAny.radius  = EditorGUILayout.FloatField("radius", bAny.radius);
                bAny.nbSides = EditorGUILayout.IntField("nbSides", bAny.nbSides);
                break;

            case PrimitiveMeshOptions.Cone:
                bAny.height  = EditorGUILayout.FloatField("height", bAny.height);
                bAny.radius  = EditorGUILayout.FloatField("radius", bAny.radius);
                bAny.nbSides = EditorGUILayout.IntField("nbSides", bAny.nbSides);
                break;

            case PrimitiveMeshOptions.Pyramid:
                bAny.height = EditorGUILayout.FloatField("height", bAny.height);
                bAny.radius = EditorGUILayout.FloatField("radius", bAny.radius);
                break;

            case PrimitiveMeshOptions.Bunny:
                break;

            case PrimitiveMeshOptions.Plane:
                bAny.length = EditorGUILayout.FloatField("length", bAny.length);
                bAny.width  = EditorGUILayout.FloatField("width", bAny.width);
                bAny.resX   = EditorGUILayout.IntField("resX", bAny.resX);
                bAny.resZ   = EditorGUILayout.IntField("resZ", bAny.resZ);
                break;

            default:
                break;
            }

            //limit the fields [Range()] doesnt work
            bAny.extents.x         = Mathf.Clamp(bAny.extents.x, 0f, 10000f);
            bAny.extents.y         = Mathf.Clamp(bAny.extents.y, 0f, 10000f);
            bAny.extents.z         = Mathf.Clamp(bAny.extents.z, 0f, 10000f);
            bAny.radius            = Mathf.Clamp(bAny.radius, 0f, 10000f);
            bAny.numLatitudeLines  = Mathf.Clamp(bAny.numLatitudeLines, 2, 100);
            bAny.numLongitudeLines = Mathf.Clamp(bAny.numLongitudeLines, 2, 100);
            bAny.height            = Mathf.Clamp(bAny.height, 0, 100);
            bAny.nbSides           = Mathf.Clamp(bAny.nbSides, 2, 100);

            bAny.length = Mathf.Clamp(bAny.length, 0, 1000);
            bAny.width  = Mathf.Clamp(bAny.width, 0, 1000);
            bAny.resX   = Mathf.Clamp(bAny.resX, 2, 100);
            bAny.resZ   = Mathf.Clamp(bAny.resZ, 2, 100);

            //AutoMagickally change settings is edited
            if (GUI.changed && bAny.imediateUpdate) //Can apply settings on editor change
            {
                ((BSoftBodyWMesh)bSoftBodyTarget).meshSettings.UserMesh = bAny.Build();
                bSoftBodyTarget.BuildSoftBody();
            }
            EditorGUILayout.TextArea("Mesh Settings");
            EditorGUILayout.Space();
        }
Ejemplo n.º 5
0
        public override void OnInspectorGUI()
        {
            serializedObject.Update();

            //Color GUIBlue = new Color32(82, 140, 255, 255);

            EditorHelpers.DrawLogoAndVersion();

            //BSoftBody sb = (BSoftBody)target;
            //sb.m_collisionFlags = BCollisionObjectEditor.RenderEnumMaskCollisionFlagsField(BCollisionObjectEditor.gcCollisionFlags, sb.m_collisionFlags);
            //sb.m_groupsIBelongTo = BCollisionObjectEditor.RenderEnumMaskCollisionFilterGroupsField(BCollisionObjectEditor.gcGroupsIBelongTo, sb.m_groupsIBelongTo);
            //sb.m_collisionMask = BCollisionObjectEditor.RenderEnumMaskCollisionFilterGroupsField(BCollisionObjectEditor.gcCollisionMask, sb.m_collisionMask);

            if (bSoftBodyTarget is BSoftBodyWMesh)
            {
                DrawCustomMeshSettingsOptions();
            }

            DrawPropertiesExcluding(serializedObject, hideMe); //Draw settings after the default inspector

            if (target is BSoftBodyPartOnSkinnedMesh)
            {
                BSoftBodyPartOnSkinnedMesh sb = (BSoftBodyPartOnSkinnedMesh)target;
                if (EditorHelpers.InspectorButton("Bind Bones To Soft Body & Nodes To Anchors", 300, 15, GUIBlue))
                {
                    sb.BindBonesToSoftBodyAndNodesToAnchors();
                }
                EditorGUILayout.HelpBox(sb.DescribeBonesAndAnchors(), MessageType.Info);
                if (sb.SoftBodySettings.sBpresetSelect != SBSettingsPresets.ShapeMatching)
                {
                    EditorGUILayout.HelpBox("For a soft body mesh the preset should probably be 'shape matching' or 'Volume'", MessageType.Warning);
                }
            }

            EditorGUILayout.BeginHorizontal();
            if (EditorHelpers.InspectorButton("Apply Preset", 100, 15, GUIBlue))
            {
                //SBSettingsPresets saveMe = bSoftBodyTarget.SoftBodySettings.sBpresetSelect;
                bSoftBodyTarget.SoftBodySettings.ResetToSoftBodyPresets(bSoftBodyTarget.SoftBodySettings.sBpresetSelect);
                //bSoftBodyTarget.SoftBodySettings.sBpresetSelect = saveMe;
            }

            bSoftBodyTarget.SoftBodySettings.sBpresetSelect = (SBSettingsPresets)EditorGUILayout.EnumPopup(bSoftBodyTarget.SoftBodySettings.sBpresetSelect);

            EditorGUILayout.EndHorizontal();
            EditorGUILayout.Space();

            //bitmask field for collisions
            bSoftBodyTarget.SoftBodySettings.config.Collisions = (BulletSharp.SoftBody.CollisionFlags)EditorGUILayout.EnumMaskField(gcCollisionTooltip, bSoftBodyTarget.SoftBodySettings.config.Collisions);

            EditorGUILayout.PropertyField(softBodySettings, gcSoftBodySettings, true);

            serializedObject.ApplyModifiedProperties();

            if (GUI.changed) //Can apply settings on editor change
            {
                bSoftBodyTarget.BuildSoftBody();
            }

            serializedObject.ApplyModifiedProperties();
        }