Сохранение моего десятичного расчета в Unity 3D - PullRequest
0 голосов
/ 05 октября 2019

Всякий раз, когда к моим вычислениям добавляется десятичное число (0,052), оно по умолчанию равно 0.

Как сохранить десятичное вычисление моего кода?

Например, int MWG = (int) (MD * постоянная );константа по умолчанию равна 0 вместо 0,052.

public class input field: MonoBehaviour
{
    private float constant = 0.052f;

public void CasingPressure()

    {

        theTVD = inputField.GetComponent<Text>().text;
        theGas = inputFieldGas.GetComponent<Text>().text;
        theMudWeight = inputFieldMudWeight.GetComponent<Text>().text;
        theInfluxLength = inputFieldLengthofInflux.GetComponent<Text>().text;
        theFormationPressure = inputFieldFormationPressure.GetComponent<Text>().text;

        int TVD = Convert.ToInt32(theTVD);
        int KD = Convert.ToInt32(theGas);
        int MW = Convert.ToInt32(theMudWeight);
        int Influx = Convert.ToInt32(theInfluxLength);
        int FP = Convert.ToInt32(theFormationPressure);

        int C = TVD + MW;

        int HP = TVD * MW * (int)(constant);
        int SDIPP = FP - HP ;
        int MD = MW - KD;
        int MWG = (int)(MD * constant);
        int LMWG = MWG * Influx;
        int SICPP = LMWG + SDIPP;
        textDisplayCP.GetComponent<Text>().text = " " + SICPP + " psi";

    }
...