Beispiel #1
0
    public void InputNewData()
    {
        // Set newDataPanel to active
        newDataPanel.SetActive(true);

        // Starting Y Position for inputFields
        float inputFieldYAxis = -17.5f;

        // Instantiate kAndWeighted prefab
        GameObject kAndWeighted = Instantiate(kAndWeightedPrefab, new Vector2(115, inputFieldYAxis), Quaternion.identity);

        // Set parent
        kAndWeighted.transform.SetParent(newDataContainer.transform, false);
        inputFieldYAxis -= 35;

        // Populate newDataPanel with inputFields for each attribute in dataset
        for (int i = 0; i < nFeatures; i++)
        {
            // Instatiate newDataPrefabs
            GameObject newInput = Instantiate(newDataInputFieldPrefab, new Vector2(115, inputFieldYAxis), Quaternion.identity);
            inputFieldYAxis -= 62;
            // Set parent
            newInput.transform.SetParent(newDataContainer.transform, false);
            // Get attribute textfield
            newInput.GetComponentInChildren <TMP_Text>().text = featureList[i];
            // Set AverageValue in inputField
            newInput.GetComponentInChildren <TMP_InputField>().text = CalculationHelpers.FindAverage(featureList[i], pointList);
        }

        // Instantiate SaveAndCancel buttons
        GameObject saveAndCancelButtons = Instantiate(saveAndCancelButtonsPrefab, new Vector2(115, inputFieldYAxis), Quaternion.identity);

        // Set parent
        saveAndCancelButtons.transform.SetParent(newDataContainer.transform, false);
        // Add onClick listener to saveButton
        saveAndCancelButtons.transform.GetChild(0).gameObject.GetComponent <Button>().onClick.AddListener(SaveButton);
        // Add onClick listener to cancelButton
        saveAndCancelButtons.transform.GetChild(1).gameObject.GetComponent <Button>().onClick.AddListener(CancelButton);

        // When newDataPanel shows, newDataButton is none-Interactable
        GameObject.FindGameObjectWithTag("PCPNewDataButton").GetComponent <Button>().interactable = false;
    }
    private void CreateWindow()
    {
        List <string> attributes = CSVläsare.columnList;

        int ypos = 224;

        for (int i = 1; i < attributes.Count - 1; ++i)
        {
            Text descrip = Instantiate(description, new Vector2(-80, ypos), Quaternion.identity) as Text;
            descrip.transform.SetParent(newDataWindow.transform, false);
            descrip.text = attributes[i];
            descrip.name = attributes[i];

            InputField inputfield = Instantiate(input, new Vector2(71, ypos), Quaternion.identity) as InputField;
            inputfield.transform.SetParent(newDataWindow.transform, false);
            inputfield.name = attributes[i];
            inputfield.text = CalculationHelpers.FindAverage(attributes[i], CSVläsare.pointList);

            ypos -= 20;
        }

        SaveData = Instantiate(button, new Vector2(71, ypos), Quaternion.identity) as Button;
        SaveData.GetComponentInChildren <Text>().text = "Save";
        SaveData.transform.SetParent(newDataWindow.transform, false);
        SaveData.onClick.AddListener(SaveInput);
        SaveData.interactable = false;



        Button CancelButton = Instantiate(button, new Vector2(71, ypos - 20), Quaternion.identity) as Button;

        CancelButton.GetComponentInChildren <Text>().text = "Cancel";
        CancelButton.onClick.AddListener(Cancel);
        CancelButton.transform.SetParent(newDataWindow.transform, false);

        newDataList.SetActive(true);
        newData.interactable = false;
        InvokeRepeating("SaveCheck", 0, 0.2f);
    }