Faced the problem of how to post an account of the game in FB and Twitter. The script itself is and everything works, but only sends messages written to the text variable. The question is how to add a variable in which the game score is recorded. The variable is in another file, in another class. It turns out to access the method from that class. But the result of this access cannot be recorded and added anywhere.
This is a piece of code in which that variable lies:
public class GameOverScript : MonoBehaviour { int score = 0; public void Start () { score = PlayerPrefs.GetInt("Score"); } ... } Script for Twitter:
public class Twitscript : MonoBehaviour { const string Address = "http://twitter.com/intent/tweet"; public void Sharetweet() { Application.OpenURL(Address + "?text=" + WWW.EscapeURL("Hurraahh! My Score in Test Game is: ") + "&url=" + WWW.EscapeURL("\t") + "&related=" + WWW.EscapeURL("\t") + "&lang=" + WWW.EscapeURL("en")); } } We need to somehow pull out the score variable from the GameOverScript class and add to this line (as I understand it) "?text=" + WWW.EscapeURL("Hurraahh! My Score in Test Game is: ")
Sharetweet()call? - Alexey ShimanskySharetweetmethodSharetweetvar myScore = GameObject.Find("ИмяОбъктаСоСкриптомGameOverScript").GetComponent<GameOverScript>().score... during the game, how and where is something recorded in thescore? and inPlayerPrefs.GetInt("Score")how and where? - Alexey Shimansky