void Crop() { float scrollPosition = gameObject.transform.Find("Scroll View").GetComponent <ScrollRect>().horizontalNormalizedPosition; GameObject confirmationDialog = Instantiate(confirmationBoxPrefab, gameObject.transform); string message = System.String.Format("Are you sure you want to delete all climb data after {0:0.0} seconds?", scrollPosition * climb.TimeTaken); confirmationDialog.transform.Find("Message").gameObject.GetComponent <Text>().text = message; confirmationDialog.transform.Find("No Button").gameObject.GetComponent <Button>().onClick.AddListener(delegate { Destroy(confirmationDialog); }); confirmationDialog.transform.Find("Yes Button").gameObject.GetComponent <Button>().onClick.AddListener(delegate { climb.Crop(scrollPosition); SceneManager.LoadScene(SceneManager.GetActiveScene().name); }); }