コード例 #1
0
 public void AcceptDropdownMenuConditions()
 {
     starSystemObjectScript.ClearAllStars(-1);
     cameraMovementScript.escMenuActiveStatus = false;
     escMenu.SetActive(false);
     initialConditionsScript.SetInitialConditions(map[dropdownMenuOptionLabelObject.GetComponent <UnityEngine.UI.Text>().text]);
     starSystemObjectScript.StartSystem();
 }
コード例 #2
0
    void OnGUI()
    {
        if (cameraMovementScript.escMenuActiveStatus == false & cameraMovementScript.cameraRotationLock == true)
        {
            haveInvalidInput = false;
            GUILayout.BeginHorizontal("box");
            GUILayout.Label("Pos x: ");
            newStarXStr = GUILayout.TextField(newStarXStr, 25, GUILayout.Width(60));
            StringToFloatCheckAndAssign(ref newStarXStr, ref newStarX);
            GUILayout.EndHorizontal();

            GUILayout.BeginHorizontal("box");
            GUILayout.Label("Pos y: ");
            newStarYStr = GUILayout.TextField(newStarYStr, 25, GUILayout.Width(60));
            StringToFloatCheckAndAssign(ref newStarYStr, ref newStarY);
            GUILayout.EndHorizontal();

            GUILayout.BeginHorizontal("box");
            GUILayout.Label("Pos z: ");
            newStarZStr = GUILayout.TextField(newStarZStr, 25, GUILayout.Width(60));
            StringToFloatCheckAndAssign(ref newStarZStr, ref newStarZ);
            GUILayout.EndHorizontal();

            GUILayout.BeginHorizontal("box");
            GUILayout.Label("V x: ");
            newStarVxStr = GUILayout.TextField(newStarVxStr, 25, GUILayout.Width(60));
            StringToFloatCheckAndAssign(ref newStarVxStr, ref newStarVx);
            GUILayout.EndHorizontal();

            GUILayout.BeginHorizontal("box");
            GUILayout.Label("V y: ");
            newStarVyStr = GUILayout.TextField(newStarVyStr, 25, GUILayout.Width(60));
            StringToFloatCheckAndAssign(ref newStarVyStr, ref newStarVy);
            GUILayout.EndHorizontal();

            GUILayout.BeginHorizontal("box");
            GUILayout.Label("V z: ");
            newStarVzStr = GUILayout.TextField(newStarVzStr, 25, GUILayout.Width(60));
            StringToFloatCheckAndAssign(ref newStarVzStr, ref newStarVz);
            GUILayout.EndHorizontal();

            GUILayout.BeginHorizontal("box");
            GUILayout.Label("Mass: ");
            newStarMassStr = GUILayout.TextField(newStarMassStr, 25, GUILayout.Width(60));
            StringToFloatCheckAndAssign(ref newStarMassStr, ref newStarMass);
            GUILayout.EndHorizontal();

            if (haveInvalidInput == true)
            {
                GUI.enabled = false;
            }
            if (GUILayout.Button("Add star"))
            {
                var newStar = Instantiate(myPrefab, new Vector3(float.Parse(newStarXStr, System.Globalization.NumberStyles.Float),
                                                                float.Parse(newStarYStr, System.Globalization.NumberStyles.Float),
                                                                float.Parse(newStarZStr, System.Globalization.NumberStyles.Float)), Quaternion.identity);

                double[] v = new double[3] {
                    double.Parse(newStarVxStr, System.Globalization.NumberStyles.Float),
                    double.Parse(newStarVyStr, System.Globalization.NumberStyles.Float),
                    double.Parse(newStarVzStr, System.Globalization.NumberStyles.Float)
                };
                newStar.GetComponent <starObject>().vel  = new VEC(3, v);
                newStar.GetComponent <starObject>().mass = float.Parse(newStarMassStr, System.Globalization.NumberStyles.Float);
                newStar.GetComponent <starObject>().lineRendererColor = Color.yellow;
            }
            if (haveInvalidInput == true)
            {
                GUI.enabled = true;
            }
            if (GUILayout.Button("Clear all stars"))
            {
                starSystemObjectScript.ClearAllStars(-1);
            }


            if (GUI.Button(new Rect(5, Screen.height - 57, 111, 23), "Start"))
            {
                if (starSystemObjectScript.systemRunning == false)
                {
                    starSystemObjectScript.StartSystem();
                    starSystemObjectScript.systemRunning = true;
                }
            }

            if (GUI.Button(new Rect(5, Screen.height - 30, 110, 23), "Pause"))
            {
                if (starSystemObjectScript.systemRunning == true)
                {
                    starSystemObjectScript.PauseSystem();
                    starSystemObjectScript.systemRunning = false;
                }
            }
        }
        if (cameraMovementScript.escMenuActiveStatus == false & displayStarInfo == true)
        {
            GUI.Label(new Rect(Screen.width - 190, Screen.height - 115, 190, 115), starInfoToDisplay);
        }
    }