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();

        }

    }

}

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

Unity3d 显示IOS基本的游戏中心脚本的更多相关文章

  1. 通过Unity3D发布IOS版游戏

    https://developer.apple.com/ 打开上面的苹果开发者网站,选择上面的"Member Center"登录进入.前提是,你注册了开发者账号,并且付了年费. 选 ...

  2. Unity3D之游戏架构脚本该如何来写(转)

    这篇文章主要想大家说明一下我在Unity3D游戏开发中是如何写游戏脚本的,对于Unity3D这套游戏引擎来说入门极快,可是要想做好却非常的难.这篇文章的目的是让哪些已经上手Unity3D游戏引擎的朋友 ...

  3. Unity3d开发IOS游戏 基础

    Unity3d开发IOS游戏 基础 @阿龙 -  649998群 1.先说明两个问题,我在WIN7下面的U3D里面,用了雅黑字体,但是导出为ios后,字体就看不见了,这是为什么呢?这是需要在MAC下找 ...

  4. Unity3D之游戏架构脚本该如何来写

    这篇文章主要想大家说明一下我在Unity3D游戏开发中是如何写游戏脚本的,对于Unity3D这套游戏引擎来说入门极快,可是要想做好却非常的难.这篇文章的目的是让哪些已经上手Unity3D游戏引擎的朋友 ...

  5. (转)Unity3D研究院之游戏架构脚本该如何来写(三十九)

     这篇文章MOMO主要想大家说明一下我在Unity3D游戏开发中是如何写游戏脚本的,对于Unity3D这套游戏引擎来说入门极快,可是要想做好却非常的难.这篇文章的目的是让哪些已经上手Unity3D游戏 ...

  6. Unity3D for iOS初级教程:Part 2/3

    转自Unity3D for iOS 这篇文章还可以在这里找到 英语 Learn how to use Unity to make a simple 3D iOS game! 这篇教材是来自教程团队成员 ...

  7. OpenNI结合Unity3D Kinect进行体感游戏开发(转)

    OpenNI结合Unity3D Kinect进行体感游戏开发(转) 楼主# 更多 发布于:2012-07-17 16:42     1. 下载安装Unity3D(目前版本为3.4)2. 下载OpenN ...

  8. Unity3d与iOS交互开发——接入平台SDK必备技能

    原地址:http://www.2cto.com/kf/201401/273337.html# 前言废话:开发手机游戏都知道,你要接入各种平台的SDK.那就需要Unity3d与iOS中Objective ...

  9. U3D 游戏引擎之游戏架构脚本该如何来写

    这篇文章MOMO主要想大家说明一下我在Unity3D游戏开发中是如何写游戏脚本的,对于Unity3D这套游戏引擎来说入门极快,可是要想做好却非常的难.这篇文章的目的是让哪些已经上手Unity3D游戏引 ...

随机推荐

  1. Linux操作命令(二)

    本次实验将介绍 Linux 命令中 mkdir.rm.mv.cp.cat.nl 命令的用法. 1.mkdir mkdir命令用来创建指定名称的目录,要求创建目录的用户在当前目录中具有写权限,并且指定的 ...

  2. JavaScript中思考do...while 和 while语句的区别

    Do...while和while...do的区别在于对于临界值的测试上.当在执行的时候只选择临界值来测试时,你会发现do...while至少要执行一次,而while...do则一次都不会执行.但是,当 ...

  3. 【分块】【暴力】XVII Open Cup named after E.V. Pankratiev Grand Prix of Moscow Workshops, Sunday, April 23, 2017 Problem I. Rage Minimum Query

    1000w的数组,一开始都是2^31-1,然后经过5*10^7次随机位置的随机修改,问你每次的全局最小值. 有效的随机修改的期望次数很少,只有当修改到的位置恰好是当前最小值的位置时才需要扫一下更新最小 ...

  4. windows下wnmp配置

    windows下面apache结合laravel会出现env文件公用的问题,太麻烦,就换用nginx.问题:https://github.com/vlucas/phpdotenv/issues/219 ...

  5. 找出最小元素 Exercise07_09

    import java.util.Scanner; /** * @author 冰樱梦 * 时间:2018年下半年 * 题目:找出最小元素 * */ public class Exercise07_0 ...

  6. Problem C: 零起点学算法82——数组中查找数

    #include<stdio.h> int main(void) { ],m; while(scanf("%d",&n)!=EOF) { ;i<n;i++ ...

  7. ES6的let和const命令

    刚开始学习es6,心里有点方,因为看了前言,感觉要用什么bebal来翻译成es5的代码,才能在各个平台上兼容运行,还有node各种运行环境. 不过自己也去百度了一些,发现还是有一丢丢的困难. 言归正传 ...

  8. UDP和TCP的区别和联系

    UDP特点 将数据源和目的封装在数据包中,不需要简历连接 每个数据报的大小在限制在64K内 因无连接,是不可靠协议 不需要建立连接,速度快 TCP 建立连接.形成传输数据通道. 在连接中进行大量数据量 ...

  9. storm性能优化

    Storm 性能优化 目录 场景假设 调优步骤和方法 Storm 的部分特性 Storm 并行度 Storm 消息机制 Storm UI 解析 性能优化 场景假设 在介绍 Storm 的性能调优方法之 ...

  10. ucenter创始人密码忘记了,修改方法

    简单的:1.在UCenter/data/下找到config.inc.php,打开找到下面2行代码: define('UC_FOUNDERPW', '3858cdf66b0794bfd435af8c0c ...