List <int> checkAnansweredAnswers(int part, int subpart)
    {
        List <int> anaswered = new List <int>();

        for (int i = 0; i < data.questionaire.parts[part].subparts[subpart].questions.Length; i++)
        {
            QuestionaireQuestion question = data.questionaire.parts[part].subparts[subpart].questions[i];

            if (question.answer == null)
            {
                anaswered.Add(i);
            }
        }

        return(anaswered);
    }
    public void Build(string referenceName, int subPartNumber = 0)
    {
        int partNumber = GetQuestionairePartIndex(referenceName);

        if (partNumber == -1)
        {
            Debug.LogError("Questionaire with Refrence name -->" + referenceName + " not found can't build interface");
            return;
        }

        if (Panel == null)
        {
            Panel = new GameObject("Questionaire Panel");

            if (Parent != null)
            {
                Panel.transform.position   = Parent.transform.position;
                Panel.transform.rotation   = Parent.transform.rotation;
                Panel.transform.localScale = new Vector3(scale, scale, scale);
                Panel.transform.Translate(adjust);
            }
        }


        Container = Instantiate(ui.Container, Panel.transform);
        GameObject PanelTitle = Instantiate(ui.PanelTitle, Container.transform);

        PanelTitle.GetComponent <TextMeshProUGUI>().text = data.questionaire.parts[partNumber].subparts[subPartNumber].name;

        if (data.questionaire.parts[partNumber].subparts[subPartNumber].description != "")
        {
            GameObject PanelDescription = Instantiate(ui.Text, Container.transform);
            PanelDescription.GetComponent <TextMeshProUGUI>().text = data.questionaire.parts[partNumber].subparts[subPartNumber].description;
        }

        for (int questionNumber = 0; questionNumber < data.questionaire.parts[partNumber].subparts[subPartNumber].questions.Length; questionNumber++)
        {
            QuestionaireQuestion question = data.questionaire.parts[partNumber].subparts[subPartNumber].questions[questionNumber];

            GameObject QuestionTitle = Instantiate(ui.Title, Container.transform);
            QuestionTitle.GetComponent <TextMeshProUGUI>().text = question.question;
            GameObject QuestionText = Instantiate(ui.Text, Container.transform);
            QuestionText.GetComponent <TextMeshProUGUI>().text = question.helpText;

            if (question.uielement == UitType.Radio)
            {
                GameObject QuestionUiElement = Instantiate(ui.Radio, Container.transform);
                QuestionUiElement.name = QuestionName(partNumber, subPartNumber, questionNumber);

                Transform ChildOption = QuestionUiElement.transform.GetChild(0);
                int       l           = QuestionUiElement.transform.childCount;
                for (int i = 1; i < l; i++)
                {
                    Transform QuestionUiElementChild = QuestionUiElement.transform.GetChild(QuestionUiElement.transform.childCount - 1);

#if UNITY_EDITOR
                    DestroyImmediate(QuestionUiElementChild.gameObject);
#else
                    Destroy(QuestionUiElementChild.gameObject);
#endif
                }


                for (int i = 0; i < question.Options.Length; i++)
                {
                    //generate captured variables for lambda functions
                    var        newPart           = partNumber;
                    var        newSubPart        = subPartNumber;
                    var        newQuestionNumber = questionNumber;
                    var        newOptionNumber   = i;
                    GameObject Option;

                    if (i == 0)
                    {
                        Option = ChildOption.gameObject;
                    }
                    else
                    {
                        Option = Instantiate(ChildOption.gameObject, QuestionUiElement.transform);
                    }

                    Option.GetComponentInChildren <TextMeshProUGUI>().text = question.Options[i];
                    VRUIRadio vruiradio = Option.GetComponentInChildren <VRUIRadio>();
                    vruiradio.onPointerClick.AddListener(delegate { RadioValueChanged(newPart, newSubPart, newQuestionNumber, newOptionNumber); });
                }

                foreach (VRUIRadio vruiradio in QuestionUiElement.GetComponentsInChildren <VRUIRadio>())
                {
                    vruiradio.isOn = false;
                }
            }
            else if (question.uielement == UitType.Slider)
            {
                //generate captured variables for lambda functions
                var newPartNumber     = partNumber;
                var newSubPartNumber  = subPartNumber;
                var newQuestionNumber = questionNumber;

                GameObject QuestionUiElement = Instantiate(ui.Slider, Container.transform);
                QuestionUiElement.name = QuestionName(newPartNumber, newSubPartNumber, newQuestionNumber);
                QuestionUiElement.GetComponentInChildren <VRUISlider>().onValueChanged.AddListener((value) => SliderValueChanged(newPartNumber, newSubPartNumber, newQuestionNumber, value));
            }
        }

        GameObject Button = Instantiate(ui.Button, Container.transform);

        if (subPartNumber == data.questionaire.parts[partNumber].subparts.Length - 1)
        {
            Button.GetComponentInChildren <Button>().onClick.AddListener(delegate { SaveQuestionaire(partNumber, subPartNumber); });
        }
        else
        {
            Button.GetComponentInChildren <Button>().onClick.AddListener(delegate { MovetoNext(partNumber, subPartNumber); });
        }


        if (MasterManager.GameSettings._devmode)
        {
            GameObject DeveloperButton = Instantiate(ui.Button, Container.transform);

            DeveloperButton.GetComponentInChildren <TextMeshProUGUI>().text = "DevForward";

            DeveloperButton.GetComponentInChildren <Button>().onClick.AddListener(delegate { OnQuestionairePartCompleted.Invoke(); });
        }
    }