- 转载地址
-
using UnityEngine;
-
using UnityEngine.SocialPlatforms;
-
-
-
{
-
// we'll create some buttons in OnGui, allowing us to bump achievement and
-
// score values for testing
-
-
private double ach1 = 0;
-
private double ach2 = 0;
-
private double ach3 = 0;
-
private double ach4 = 0;
-
-
private long score1 = 1000;
-
private long score2 = 200;
-
-
private int buttonWidth = 120;
-
private int buttonHeight = 50;
-
private int buttonGap = 10;
-
-
-
{
-
-
}
-
-
// authentication
-
-
private void HandleAuthenticated
(bool success)
-
{
-
-
-
-
-
-
}
-
}
-
-
private void HandleFriendsLoaded
(bool success)
-
{
-
-
-
-
}
-
}
-
-
private void HandleAchievementsLoaded
(IAchievement[] achievements
)
-
{
-
Debug.
Log("*** HandleAchievementsLoaded");
-
-
-
}
-
}
-
-
-
{
-
Debug.
Log("*** HandleAchievementDescriptionsLoaded");
-
-
-
}
-
}
-
-
// achievements
-
-
-
{
-
-
-
}
-
}
-
-
private void HandleProgressReported
(bool success)
-
{
-
-
}
-
-
public void ShowAchievements()
-
{
-
-
-
}
-
}
-
-
// leaderboard
-
-
public void ReportScore(string leaderboardId,
long score
)
-
{
-
-
-
}
-
}
-
-
public void HandleScoreReported
(bool success)
-
{
-
-
}
-
-
public void ShowLeaderboard()
-
{
-
-
-
}
-
}
-
-
// gui
-
-
-
{
-
// four buttons, allowing us to bump and test setting achievements
-
int yDelta = buttonGap;
-
if (GUI.
Button(new Rect(buttonGap, yDelta, buttonWidth, buttonHeight
),
"Ach 1")) {
-
-
ach1 = (ach1 == 100) ? 0 : ach1 + 10;
-
}
-
yDelta += buttonHeight + buttonGap;
-
if (GUI.
Button(new Rect(buttonGap, yDelta, buttonWidth, buttonHeight
),
"Ach 2")) {
-
-
ach2 = (ach2 == 100) ? 0 : ach2 + 10;
-
}
-
yDelta += buttonHeight + buttonGap;
-
if (GUI.
Button(new Rect(buttonGap, yDelta, buttonWidth, buttonHeight
),
"Ach 3")) {
-
-
ach3 = (ach3 == 100) ? 0 : ach3 + 10;
-
}
-
yDelta += buttonHeight + buttonGap;
-
if (GUI.
Button(new Rect(buttonGap, yDelta, buttonWidth, buttonHeight
),
"Ach 4")) {
-
-
ach4 = (ach4 == 100) ? 0 : ach4 + 10;
-
}
-
// show achievements
-
yDelta += buttonHeight + buttonGap;
-
if (GUI.
Button(new Rect(buttonGap, yDelta, buttonWidth, buttonHeight
),
"Show Achievements")) {
-
ShowAchievements();
-
}
-
-
// two buttons, allowing us to bump and test setting high scores
-
int xDelta =
Screen.
width - buttonWidth - buttonGap;
-
yDelta = buttonGap;
-
if (GUI.
Button(new Rect(xDelta, yDelta, buttonWidth, buttonHeight
),
"Score 1")) {
-
-
score1 += 500;
-
}
-
yDelta += buttonHeight + buttonGap;
-
if (GUI.
Button(new Rect(xDelta, yDelta, buttonWidth, buttonHeight
),
"Score 2")) {
-
-
score2 += 100;
-
}
-
// show leaderboard
-
yDelta += buttonHeight + buttonGap;
-
if (GUI.
Button(new Rect(xDelta, yDelta, buttonWidth, buttonHeight
),
"Show Leaderboard")) {
-
ShowLeaderboard();
-
}
-
}
-
}