- Home /
Question by
siaknimarkanthony · Feb 06, 2018 at 03:42 PM ·
uiinputscoreleaderboard
How to change scoreInputField to get a score from another script/Scene
Hi guys, I want to get the score from my GameController Script instead of making an InputField for my score to call on another script called HIghScoreManager. Should i make a public String or int to call the score? thank you for the answers.
In my GameController Script i used Playerprefs to call scores from other script.
PlayerPrefs.SetInt("TOTAL_SCORE", totalScore);
PlayerPrefs.Save();
and This is the HighScoreManager which i want to call the total score from the gamecontroller.
[SerializeField] private InputField _nameInputField = null;
[SerializeField] private InputField _scoreInputField = null; //the line which i want to call my the Final score.
public void OnRecordButton () {
int score;
if (!int.TryParse(_scoreInputField.text, out score)) { /* invalid score entered */ return; } //calling from by this line
if (string.IsNullOrEmpty(_nameInputField.text)) { /* no name entered */ return; }
Leaderboard.Record(_nameInputField.text, score);
_nameInputField.text = "";
_scoreInputField.text = "0";
}
Comment