Tic Tac Toe Example AchievementsLobby - TogetherGames/Public-Unity-CSharp GitHub Wiki
The AchievementsLobby screen displays a list of Achievements configured in the game. Developers are resposible for creating and maintaining these Achievements. When the User presses a button representing an Achievement, the Achievement screen is display.
The Start() method calls AchievementManager.GetAll() method to retrieve all game configured Achievements.
Together.Instance.AchievementManager.GetAll(onAllAchievementsRetrieved); // callbackFunc
The DisplayButtons() method displays a button for every Achievement configured in the Game.
void DisplayButtons()
{
if( GUI.Button(new Rect(10, 50, 100, 50), "Back"))
Application.LoadLevel("MainMenu");
//if( GUI.Button(new Rect((Screen.width - 200) * 0.5f, 200 + (60 * i), 200, 50), "Achievment1"))
// Application.LoadLevel("Achievement");
if(m_bDisplay)
{
for (int i = 0; i < m_Achievements.Length; i++)
{
string display = "ID=" + m_Achievements[i].AchievementID + ", Name=" + m_Achievements[i].Name + ", Action=" + m_Achievements[i].ActionName;
if( GUI.Button(new Rect((Screen.width - 400) * 0.5f, 200 + (60 * i), buttonWidth, 50), display))
{
Helper.UserData = m_Achievements[i];
Application.LoadLevel("Achievement");
}
}
}
}
When an Achievement button is pressed, the Achievement pressed is assigned to the Helper.UserData member before the Achievement scene is loaded. The Helper.UserData member is used to pass initialization data from one screen to another.
if( GUI.Button(new Rect((Screen.width - 400) * 0.5f, 200 + (60 * i), buttonWidth, 50), display))
{
Helper.UserData = m_Achievements[i];
Application.LoadLevel("Achievement");
}