Exemple #1
0
    // private void Awake()
    // {
    //     axes.SetActive(true);
    //     space.GetComponent<Space>().enabled = false;
    //
    //    spoofbodylist = savedSimulations.simulationList[savedSimulations.selectedB];
    //
    //     foreach (var spoofBody in spoofbodylist)
    //     {
    //         bodyInstance = Instantiate(linedSp) as GameObject;
    //         bodyInstanceCbody = bodyInstance.GetComponent<Cbody>();
    //
    //         bodyInstanceCbody.m = spoofBody.mass;
    //         bodyInstanceCbody.setMass();
    //
    //         bodyInstanceCbody.radius = spoofBody.radius;
    //         bodyInstanceCbody.setRadius();
    //
    //         bodyInstanceCbody.initialPos = spoofBody.initialPos;
    //         bodyInstanceCbody.setInitialPos();
    //
    //         bodyInstanceCbody.initialVel = spoofBody.initialVel;
    //         bodyInstanceCbody.setIntialVel();
    //     }
    //     lines = FindObjectsOfType<nullScriptforVtoggle>();
    //
    //     CB = FindObjectsOfType<Cbody>();
    //
    // }


    private void Awake()
    {
        if (File.Exists(Application.persistentDataPath + "/" + savedSimulations.selectedB + ".CBSarrayHolder"))
        {
            BinaryFormatter bf   = new BinaryFormatter();
            FileStream      file = File.Open(Application.persistentDataPath + "/" + savedSimulations.selectedB + ".CBSarrayHolder", FileMode.Open);
            CBSarrayHolder  save = (CBSarrayHolder)bf.Deserialize(file);
            file.Close();

            CbodySpoof[] CBS = save.CBS;

            foreach (var spoofBody in CBS)
            {
                bodyInstance      = Instantiate(linedSp) as GameObject;
                bodyInstanceCbody = bodyInstance.GetComponent <Cbody>();


                bodyInstanceCbody.m = spoofBody.mass;
                bodyInstanceCbody.setMass();

                bodyInstanceCbody.radius = spoofBody.radius;
                bodyInstanceCbody.setRadius();

                bodyInstanceCbody.initialPos = new Vector3(spoofBody.initialPos.x, spoofBody.initialPos.y, spoofBody.initialPos.z);
                bodyInstanceCbody.setInitialPos();

                bodyInstanceCbody.initialVel = new Vector3(spoofBody.initialVel.x, spoofBody.initialVel.y, spoofBody.initialVel.z);
                bodyInstanceCbody.setIntialVel();
            }
        }
        lines = FindObjectsOfType <nullScriptforVtoggle>();

        CB = FindObjectsOfType <Cbody>();
    }
    public void setProperties()
    {
        cbody = gamemanagerTes.bodyselected.GetComponent <Cbody>();

        cbody.radius = GetFloat(radiusI.text, 0.0f);
        cbody.setRadius();

        cbody.m = GetFloat(massI.text, 0.0f);
        cbody.setMass();

        cbody.initialPos = new Vector3(GetFloat(posxI.text, 0.0f), GetFloat(posyI.text, 0.0f), GetFloat(poszI.text, 0.0f));
        cbody.setInitialPos();

        cbody.initialVel = new Vector3(GetFloat(velxI.text, 0.0f), GetFloat(velyI.text, 0.0f), GetFloat(velzI.text, 0.0f));
        cbody.setIntialVel();
    }