void OnTriggerStay(Collider other)
    {
        RealisticBuoyancy RB = other.GetComponent <RealisticBuoyancy>();

        if (RB != null && other.transform.position.y < RealisticWaterPhysics.currentWaterLevel)
        {
            other.attachedRigidbody.AddForce(-transform.right * (currentForce * RB.getMass));
        }
    }
Beispiel #2
0
    void importSettingsFromSelectedGameObject()
    {
        clearTestResults();

        if (SelectedObject.GetComponent <RealisticBuoyancy>() == true)
        {
            RealisticBuoyancy BuoyancyScript = SelectedObject.GetComponent <RealisticBuoyancy>();

            slicesPerAxis           = BuoyancyScript.slicesPerAxis;
            isConcave               = BuoyancyScript.isConcave;
            voxelsLimit             = BuoyancyScript.voxelsLimit;
            percentageSolid         = BuoyancyScript.percentageSolid;
            SelectedMaterialType    = BuoyancyScript.SelectedMaterialType;
            selectedGasesMaterial   = BuoyancyScript.selectedGasesMaterial;
            selectedLiquidsMaterial = BuoyancyScript.selectedLiquidsMaterial;
            selectedSolidsMaterial  = BuoyancyScript.selectedSolidsMaterial;

            if (BuoyancyScript.SelectedMaterialType != MaterialTypes.Solid)
            {
                ShowAdvancedInfo = true;
            }

            if (slicesPerAxis == 1)
            {
                selectedFloatingQuality = FloatingQuality.ExtremeLow;
            }
            if (slicesPerAxis == 2)
            {
                selectedFloatingQuality = FloatingQuality.Low;
            }
            if (slicesPerAxis == 4)
            {
                selectedFloatingQuality = FloatingQuality.Medium;
            }

            if (slicesPerAxis == 6)
            {
                selectedFloatingQuality = FloatingQuality.High;
            }

            if (slicesPerAxis == 8)
            {
                selectedFloatingQuality = FloatingQuality.ExtremeHigh;
            }
        }
        else
        {
            //Cant find settings to import.
            //Nothing wrong with that!
        }
    }
Beispiel #3
0
    void addOrUpdateFloatingComponent(GameObject SelectedObj)
    {
        RealisticBuoyancy addedBuoyancyScript = SelectedObj.GetComponent <RealisticBuoyancy>();

        addedBuoyancyScript.slicesPerAxis           = slicesPerAxis;
        addedBuoyancyScript.isConcave               = isConcave;
        addedBuoyancyScript.voxelsLimit             = voxelsLimit;
        addedBuoyancyScript.percentageSolid         = percentageSolid;
        addedBuoyancyScript.SelectedMaterialType    = SelectedMaterialType;
        addedBuoyancyScript.selectedGasesMaterial   = selectedGasesMaterial;
        addedBuoyancyScript.selectedLiquidsMaterial = selectedLiquidsMaterial;
        addedBuoyancyScript.selectedSolidsMaterial  = selectedSolidsMaterial;
        addedBuoyancyScript.LightRunTimeEdits       = LightRunTimeEdits;
        addedBuoyancyScript.HeavyRunTimeEdits       = HeavyRunTimeEdits;
        addedBuoyancyScript.reSetup();
        Debug.Log("Created / Updated script");
    }
Beispiel #4
0
    public override void OnInspectorGUI()
    {
        if (textureLogo == null)
        {
            textureLogo = (Texture2D)EditorGUIUtility.Load("Assets/RealisticPhysics/RealisticWaterPhysics/Resources/icon.png");
        }
        EditorGUILayout.BeginHorizontal();
        GUILayout.FlexibleSpace();
        GUILayout.Label(textureLogo);
        GUILayout.FlexibleSpace();
        EditorGUILayout.EndHorizontal();

        RealisticBuoyancy realisticBuoyancy = (RealisticBuoyancy)target;

        realisticBuoyancy.BuoyancyEnabled = EditorGUILayout.Toggle("Buoyancy enabled", realisticBuoyancy.BuoyancyEnabled);

        EditorGUILayout.Space();

        EditorGUILayout.LabelField("Run time modifications:");
        realisticBuoyancy.LightRunTimeEdits = EditorGUILayout.Toggle("Light edits", realisticBuoyancy.LightRunTimeEdits);
        realisticBuoyancy.HeavyRunTimeEdits = EditorGUILayout.Toggle("Heavy edits", realisticBuoyancy.HeavyRunTimeEdits);

        if (realisticBuoyancy.LightRunTimeEdits || realisticBuoyancy.HeavyRunTimeEdits)
        {
            EditorGUILayout.Space();

            EditorGUILayout.LabelField("Objects properies:");
            EditorGUILayout.BeginHorizontal();
            EditorGUILayout.LabelField("Percentage solid: ");
            realisticBuoyancy.percentageSolid = EditorGUILayout.IntSlider(realisticBuoyancy.percentageSolid, 0, 100);
            EditorGUILayout.EndHorizontal();
            EditorGUILayout.LabelField("Density: ", realisticBuoyancy.CalculatedDensity);
            EditorGUILayout.LabelField("Mass: ", realisticBuoyancy.CalculatedMass);
            EditorGUILayout.LabelField("Volume: ", realisticBuoyancy.CalculatedVolume);

            EditorGUILayout.Space();
            EditorGUILayout.LabelField("Material type: ", realisticBuoyancy.infoMaterialType);
            EditorGUILayout.LabelField("Material sub type: ", realisticBuoyancy.infoSubType);
        }
    }