Tic Tac Toe Example UserAchievementsLobby - TogetherGames/Public-Unity-CSharp GitHub Wiki
The UserAchievementsLobby screen displays a list of UserAchievements the User has obtained. When the User presses a button representing an UserAchievement, the UserAchievement screen is display.
The Start() method calls UserAchievementManager.GetAll() method to retrieve all UserAchievements the logged in User has obtained.
Together.Instance.User.UserAchievementManager.GetAll(onAllUserAchievementsRetrieved);
The DisplayButtons() method displays a button for every UserAchievement retrieved.
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, 200, 50), "UserAchievement1"))
// Application.LoadLevel("UserAchievement");
if(m_bDisplay)
{
for (int i = 0; i <= m_UserAchievements.Length-1; i++)
{
string display = "ID=" + m_UserAchievements[i].UserAchievementID +
", Name=" + m_UserAchievements[i].Achievement.Name + ", " + m_UserAchievements[i].RequiredCount +
"/" + m_UserAchievements[i].Achievement.RequiredCount +
", Compl=" + m_UserAchievements[i].Completed.ToString();
if( GUI.Button(new Rect((Screen.width - 400) * 0.5f, 200 + (60 * i), buttonWidth, 50), display))
{
Helper.UserData = m_UserAchievements[i];
Application.LoadLevel("UserAchievement");
}
}
}
}
When a UserAchievement button is pressed, the UserAchievement pressed is assigned to the Helper.UserData member before the UserAchievement 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_UserAchievements[i];
Application.LoadLevel("UserAchievement");
}