/// <summary> /// Hides the buttons of analytical algorithms and shows the outcome of the executed one. /// </summary> /// <param name="instance"></param> private void ChangeButtonsForResults(AnalyticsScript instance) { instance.AddResults(instance.ToString()); ContainerViewPort cv = inheritor; cv.ShowPanel(resultPanel); cv.StatusText.text = "Showing Results of " + instance.ToString(); foreach (DictionaryEntry result in instance.Results) { GameObject textmeshKey = NewGameObject(resultPanel, textMesh); GameObject textmeshValue = NewGameObject(resultPanel, textMesh); textmeshKey.GetComponent <TextMeshProUGUI>().SetText((string)result.Key); textmeshValue.GetComponent <TextMeshProUGUI>().SetText(result.Value.ToString()); } }
/// <summary> /// Standard starting function. It generates an interactable button for each /// script implementing the AnalyticsScript abstract class. /// </summary> void Start() { List <string> scripts = GlobalVariables.GetFilesFrom("Analyticsscripts", "cs"); var type = typeof(AnalyticsScript); var types = AppDomain.CurrentDomain.GetAssemblies() .SelectMany(s => s.GetTypes()) .Where(p => type.IsAssignableFrom(p) && p != typeof(AnalyticsScript)).ToList(); Debug.Log(types.Count); for (int i = 0; i < types.Count; i++) { //Debug.Log(scripts[i]); AnalyticsScript instance = (AnalyticsScript)Activator.CreateInstance(types[i]); if (instance.HasGuiButton) { GameObject btn = NewGameObject(PanelToShow, lookOfButtons); //original //btn.transform.GetChild(0).GetComponent<Text>().text = scripts[i]; //modified btn.transform.GetChild(0).GetComponent <Text>().text = types[i].ToString(); btn.GetComponent <Button>().onClick.AddListener(() => { instance.Nodes = GlobalVariables.GetGraphNodes(1); instance.Links = GlobalVariables.GetGraphLinks(1); instance.Execute(); }); if (instance.HasResultButton) { btn.GetComponent <Button>().onClick.AddListener(() => { ChangeButtonsForResults(instance); }); } } } }