void levelCompleted() { int bonus = 100 - (int)Pb.BarValue; int total_score = (gameObject.GetComponent <PiecesInfo>().piece_Count) * 10 + bonus; level_started = 0; if (PlayerPrefs.GetInt(gameObject.GetComponent <PiecesInfo>().level_name) == 0) { PlayerPrefs.SetInt(gameObject.GetComponent <PiecesInfo>().level_name, total_score); } if (PlayerPrefs.GetInt(gameObject.GetComponent <PiecesInfo>().level_name) < total_score) { PlayerPrefs.SetInt(gameObject.GetComponent <PiecesInfo>().level_name, total_score); } Share share_obj = gameObject.GetComponent <Share>(); share_obj.CaptureScreenshot(); StartCoroutine(WaitForScreenshot(total_score)); //Save current score as high score if more than high score }