原地址:

http://forum.unity3d.com/threads/116901-Game-Center-Support/page3

using UnityEngine;
using UnityEngine.SocialPlatforms; public class Startup : MonoBehaviour
{
// we'll create some buttons in OnGui, allowing us to bump achievement and
// score values for testing private double ach1 = ;
private double ach2 = ;
private double ach3 = ;
private double ach4 = ; private long score1 = ;
private long score2 = ; private int buttonWidth = ;
private int buttonHeight = ;
private int buttonGap = ; void Start()
{
Social.localUser.Authenticate(HandleAuthenticated);
} // authentication private void HandleAuthenticated(bool success)
{
Debug.Log("*** HandleAuthenticated: success = " + success);
if (success) {
Social.localUser.LoadFriends(HandleFriendsLoaded);
Social.LoadAchievements(HandleAchievementsLoaded);
Social.LoadAchievementDescriptions(HandleAchievementDescriptionsLoaded);
}
} private void HandleFriendsLoaded(bool success)
{
Debug.Log("*** HandleFriendsLoaded: success = " + success);
foreach (IUserProfile friend in Social.localUser.friends) {
Debug.Log("* friend = " + friend.ToString());
}
} private void HandleAchievementsLoaded(IAchievement[] achievements)
{
Debug.Log("*** HandleAchievementsLoaded");
foreach (IAchievement achievement in achievements) {
Debug.Log("* achievement = " + achievement.ToString());
}
} private void HandleAchievementDescriptionsLoaded(IAchievementDescription[] achievementDescriptions)
{
Debug.Log("*** HandleAchievementDescriptionsLoaded");
foreach (IAchievementDescription achievementDescription in achievementDescriptions) {
Debug.Log("* achievementDescription = " + achievementDescription.ToString());
}
} // achievements public void ReportProgress(string achievementId, double progress)
{
if (Social.localUser.authenticated) {
Social.ReportProgress(achievementId, progress, HandleProgressReported);
}
} private void HandleProgressReported(bool success)
{
Debug.Log("*** HandleProgressReported: success = " + success);
} public void ShowAchievements()
{
if (Social.localUser.authenticated) {
Social.ShowAchievementsUI();
}
} // leaderboard public void ReportScore(string leaderboardId, long score)
{
if (Social.localUser.authenticated) {
Social.ReportScore(score, leaderboardId, HandleScoreReported);
}
} public void HandleScoreReported(bool success)
{
Debug.Log("*** HandleScoreReported: success = " + success);
} public void ShowLeaderboard()
{
if (Social.localUser.authenticated) {
Social.ShowLeaderboardUI();
}
} // gui public void OnGUI()
{
// four buttons, allowing us to bump and test setting achievements
int yDelta = buttonGap;
if (GUI.Button(new Rect(buttonGap, yDelta, buttonWidth, buttonHeight), "Ach 1")) {
ReportProgress("A0001", ach1);
ach1 = (ach1 == ) ? : ach1 + ;
}
yDelta += buttonHeight + buttonGap;
if (GUI.Button(new Rect(buttonGap, yDelta, buttonWidth, buttonHeight), "Ach 2")) {
ReportProgress("A0002", ach2);
ach2 = (ach2 == ) ? : ach2 + ;
}
yDelta += buttonHeight + buttonGap;
if (GUI.Button(new Rect(buttonGap, yDelta, buttonWidth, buttonHeight), "Ach 3")) {
ReportProgress("A0003", ach3);
ach3 = (ach3 == ) ? : ach3 + ;
}
yDelta += buttonHeight + buttonGap;
if (GUI.Button(new Rect(buttonGap, yDelta, buttonWidth, buttonHeight), "Ach 4")) {
ReportProgress("A0004", ach4);
ach4 = (ach4 == ) ? : ach4 + ;
}
// 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")) {
ReportScore("L01", score1);
score1 += ;
}
yDelta += buttonHeight + buttonGap;
if (GUI.Button(new Rect(xDelta, yDelta, buttonWidth, buttonHeight), "Score 2")) {
ReportScore("L02", score2);
score2 += ;
}
// show leaderboard
yDelta += buttonHeight + buttonGap;
if (GUI.Button(new Rect(xDelta, yDelta, buttonWidth, buttonHeight), "Show Leaderboard")) {
ShowLeaderboard();
}
}
}

Unity3.5 GameCenter基础教程(转载)的更多相关文章

  1. jQuery官方基础教程笔记(转载)

    本文转载于阮一峰的博文,内容基础,结构清晰,是jquery入门不可多得的资料,非常好,赞一个. 阮一峰:jQuery官方基础教程笔记 jQuery是目前使用最广泛的javascript函数库. 据统计 ...

  2. [转载] 《Hadoop基础教程》之初识Hadoop

    转载自http://blessht.iteye.com/blog/2095675 Hadoop一直是我想学习的技术,正巧最近项目组要做电子商城,我就开始研究Hadoop,虽然最后鉴定Hadoop不适用 ...

  3. 《Hadoop基础教程》之初识Hadoop(转载)

    转载自博主:上善若水任方圆http://blessht.iteye.com/blog/2095675 Hadoop一直是我想学习的技术,正巧最近项目组要做电子商城,我就开始研究Hadoop,虽然最后鉴 ...

  4. [转载]Unity3D游戏引擎最详尽基础教程

    原文地址:Unity3D游戏引擎最详尽基础教程作者:ShangShang 我一直向所有想做游戏的朋友推荐Unity3D,为什么呢?首先是因为专业,Unity3D非常强大,用它创建一个类似MiniGor ...

  5. <<Bootstrap基础教程>> 新书出手,有心栽花花不开,无心插柳柳成荫

    并非闲的蛋疼,做技术也经常喜欢蛋疼,纠结于各种技术,各种需求变更,还有一个很苦恼的就是UI总是那么不尽人意.前不久自己开源了自己做了多年的仓储项目(开源地址:https://github.com/he ...

  6. html快速入门(基础教程+资源推荐)

    1.html究竟是什么? 从字面上理解,html是超文本标记语言hyper text mark-up language的首字母缩写,指的是一种通用web页面描述语言,是用来描述我们打开浏览器就能看到的 ...

  7. 【Unity3D基础教程】给初学者看的Unity教程(四):通过制作Flappy Bird了解Native 2D中的RigidBody2D和Collider2D

    作者:王选易,出处:http://www.cnblogs.com/neverdie/ 欢迎转载,也请保留这段声明.如果你喜欢这篇文章,请点[推荐].谢谢! 引子 在第一篇文章[Unity3D基础教程] ...

  8. WCF基础教程之异常处理:你的Try..Catch语句真的能捕获到异常吗?

    在上一篇WCF基础教程之开篇:创建.测试和调用WCF博客中,我们简单的介绍了如何创建一个WCF服务并调用这个服务.其实,上一篇博客主要是为了今天这篇博客做铺垫,考虑到网上大多数WCF教程都是从基础讲起 ...

  9. Django 基础教程

    Django 基础教程 这是第一篇 Django 简介 »  Django 是由 Python 开发的一个免费的开源网站框架,可以用于快速搭建高性能,优雅的网站! 你一定可以学会,Django 很简单 ...

随机推荐

  1. CodeForces 738C Road to Cinema

    二分答案. 油量越多,显然通过的时间越少.可以二分找到最小的油量,可以在$t$时间内到达电影院. 一个油箱容量为$v$的车通过长度为$L$的路程需要的最小时间为$max(L,3*L-v)$.计算过程如 ...

  2. 一个菜鸟正在用SSH写一个论坛(2)

    额 一不小心又一个多月没有写过随笔了. 这次是在某次启动服务器的时候报错了: 严重: Exception starting filter struts2 Unable to load configur ...

  3. 【Bzoj4555】【Luogu P4091】求和(NTT)

    题面 Bzoj Luogu 题解 先来颓柿子 $$ \sum_{i=0}^n\sum_{j=0}^iS(i,j)2^jj! \\ =\sum_{j=0}^n2^jj!\sum_{i=0}^nS(i,j ...

  4. [xsy1144]选物品

    题意:给定$a_{1\cdots n},b_{1\cdots n}$,询问是给定$l,r$,找出$a',b'$使得$\sum\limits_{i=l}^r\max(\left|a'-a_i\right ...

  5. Problem G: 零起点学算法106——首字母变大写

    #include<stdio.h> #include<string.h> int main(void) { ]; int i,k; while(gets(a)!=NULL) { ...

  6. Manthan, Codefest 16 B. A Trivial Problem 二分 数学

    B. A Trivial Problem 题目连接: http://www.codeforces.com/contest/633/problem/B Description Mr. Santa ask ...

  7. RequireJS 与 SeaJS 的异同

    相同之处 RequireJS 和 SeaJS 都是模块加载器,倡导的是一种模块化开发理念,核心价值是让 JavaScript 的模块化开发变得更简单自然. 不同之处 两者的区别如下: 定位有差异.Re ...

  8. Linux PHP 编译参数详解(一)

    Fast-CGI: ./configure --prefix=/usr/local/php --enable-fastcgi --enable-force-cgi-redirect --with-co ...

  9. Cargo, Rust’s Package Manager

    http://doc.crates.io/ Installing The easiest way to get Cargo is to get the current stable release o ...

  10. Visio显示不完整

    下面显示不完整的话,选中对象,菜单栏设置(点击对象,右键并没有段落选项)行距为单倍:右侧显示不完整,选中后右键设置环绕方式为负于文字上方,原来是嵌入型.