Ejemplo n.º 1
0
        [MenuItem("GameObject/Create Other/BulletForUnity/BSoftBody/BSoftBodyWMesh")]  //right click menu
        static void CreateBSoftWithMesh()
        {
            BAnyMeshSettings settings = new BAnyMeshSettings();

            settings.meshType      = PrimitiveMeshOptions.Bunny;
            Selection.activeObject = BSoftBodyWMesh.CreateNew(EditorHelpers.GetCameraRaycastPosition(), Quaternion.identity, settings.Build(), true, SBSettingsPresets.ShapeMatching);
            PostCreateObject();
        }
        void Update()
        {
            //Update presets if changed
            if (SBPresetSelect != lastSBPresetSelect)
            {
                SoftBodySettings.ResetToSoftBodyPresets(SBPresetSelect);
            }
            lastSBPresetSelect = SBPresetSelect;

            if (!enableRain)
            {
                return;
            }
            if ((Time.time - lastBunnyTime) > (1 / softBodiesPerSecond))
            {
                Vector3 pos = new Vector3(0, 0, 0);

                pos.x = startAreaOfRain.center.x + UnityEngine.Random.Range(-startAreaOfRain.width / 2, startAreaOfRain.width / 2);
                pos.z = startAreaOfRain.center.y + UnityEngine.Random.Range(-startAreaOfRain.height / 2, startAreaOfRain.height / 2);
                pos.y = fromHeight;

                GameObject     go    = BSoftBodyWMesh.CreateNew(pos, UnityEngine.Random.rotation, anyMeshSettings.Build(), false, SBPresetSelect);
                BSoftBodyWMesh bSoft = go.GetComponent <BSoftBodyWMesh>();

                bSoft.meshSettings.autoWeldVertices     = anyMeshSettings.autoWeldVertices;
                bSoft.meshSettings.autoWeldThreshold    = anyMeshSettings.autoWeldThreshold;
                bSoft.meshSettings.recalculateNormals   = anyMeshSettings.recalculateNormals;
                bSoft.meshSettings.addBackFaceTriangles = anyMeshSettings.addBackFaceTriangles;
                bSoft.meshSettings.recalculateBounds    = anyMeshSettings.recalculateBounds;
                //bSoft.meshSettings.optimize = anyMeshSettings.optimize;

                bSoft.SoftBodySettings = SoftBodySettings;                  //play with settings

                //bSoft.SoftBodySettings.config.Collisions = collisionMask;

                bSoft._BuildCollisionObject();

                //randomize color for effect
                go.GetComponent <MeshRenderer>().material.color =
                    new Color(UnityEngine.Random.Range(0.0f, 1.0f), UnityEngine.Random.Range(0.0f, 1.0f), UnityEngine.Random.Range(0.0f, 1.0f));

                Destroy(go, lifetime);

                lastBunnyTime = Time.time;
            }
        }
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();
 }