孙广东  2015.12.23

Social API

Social API 是訪问的Unity 的point 社会功能。如:
• 用户配置文件
• 好友列表
• 成就
• 统计 / 排行榜

     它提供了不同的social 后端。如 XBox Live 或 GameCenter,一个统一的接口,主要为了由程序猿在游戏项目上使用。

  Social API 主要是异步的 API。并使用它的典型方式是 通过一个函数调用 和注冊一个回调方法向该函数完毕时。异步函数可能有副作用。如 增生某些状态变量在 API 中,和回调可能包括来自服务器要处理的数据。

   Social 类驻留在 UnityEngine 命名空间中,所以始终是可用。但其它社会 API 类都保存在自己的命名空间,UnityEngine.SocialPlatforms. Furthermore。

此外。Social  API 的实现是在子命名空间,如 SocialPlatforms.GameCenter。

     在这里是一个样例 (JavaScript) 怎样使用Social  API:

import UnityEngine.SocialPlatforms;

function Start () {
// Authenticate and register a ProcessAuthentication callback
// This call needs to be made before we can proceed to other calls in the Social API
Social.localUser.Authenticate (ProcessAuthentication);
} // This function gets called when Authenticate completes
// Note that if the operation is successful, Social.localUser will contain data from the server.
function ProcessAuthentication (success: boolean) {
if (success) {
Debug.Log ("Authenticated, checking achievements"); // Request loaded achievements, and register a callback for processing them
Social.LoadAchievements (ProcessLoadedAchievements);
}
else
Debug.Log ("Failed to authenticate");
} // This function gets called when the LoadAchievement call completes
function ProcessLoadedAchievements (achievements: IAchievement[]) {
if (achievements.Length == 0)
Debug.Log ("Error: no achievements found");
else
Debug.Log ("Got " + achievements.Length + " achievements"); // You can also call into the functions like this
Social.ReportProgress ("Achievement01", 100.0, function(result) {
if (result)
Debug.Log ("Successfully reported achievement progress");
else
Debug.Log ("Failed to report achievement");
});
}
using UnityEngine;
using UnityEngine.SocialPlatforms; public class SocialExample : MonoBehaviour { void Start () {
// Authenticate and register a ProcessAuthentication callback
// This call needs to be made before we can proceed to other calls in the Social API
Social.localUser.Authenticate (ProcessAuthentication);
} // This function gets called when Authenticate completes
// Note that if the operation is successful, Social.localUser will contain data from the server.
void ProcessAuthentication (bool success) {
if (success) {
Debug.Log ("Authenticated, checking achievements"); // Request loaded achievements, and register a callback for processing them
Social.LoadAchievements (ProcessLoadedAchievements);
}
else
Debug.Log ("Failed to authenticate");
} // This function gets called when the LoadAchievement call completes
void ProcessLoadedAchievements (IAchievement[] achievements) {
if (achievements.Length == 0)
Debug.Log ("Error: no achievements found");
else
Debug.Log ("Got " + achievements.Length + " achievements"); // You can also call into the functions like this
Social.ReportProgress ("Achievement01", 100.0, result => {
if (result)
Debug.Log ("Successfully reported achievement progress");
else
Debug.Log ("Failed to report achievement");
});
}
}

对Social API的很多其它信息。看看Social API脚本參考

还有 See Also: GameCenterPlatform.类

unity的 Social API的更多相关文章

  1. Unity的常用API

    1.Event Function:事件函数   Reset() :被附加脚本时.在游戏物体的组件上按Reset时会触发该事件函数 Start() :在游戏初始化时会执行一次 Update() :每一帧 ...

  2. Unity 相关经典博客资源总结(持续更新)

    就作为一个记录吧,把平时看过的Unity相关的一些好的Blog记录并分享. 好的论坛: Unity官方脚本  点评:这个不用说了,最核心的内容,理解整个Unity引擎的方方面面,梳理结构. Unity ...

  3. HoloLens开发手记 - Unity development overview 使用Unity开发概述

    Unity Technical Preview for HoloLens最新发行版为:Beta 24,发布于 09/07/2016 开始使用Unity开发HoloLens应用之前,确保你已经安装好了必 ...

  4. Unity Assets目录下的特殊文件夹名称

    1.隐藏文件夹以.开头的文件夹会被Unity忽略.在这种文件夹中的资源不会被导入,脚本不会被编译.也不会出现在Project视图中.2.Standard Assets在这个文件夹中的脚本最先被编译.这 ...

  5. 【Unity基础知识之三】Unity Assets目录下的特殊文件夹名称

    Unity3D的特殊目录名称   Unity预留了一些目录名称,这些目录有着特殊的含义.比较重要的有: Resources这个目录下的所有文件都会被打包到发布版本中,程序可以通过文件路径来访问它们.这 ...

  6. unity两点之间抛物线,完美金手指

    学校享受的日子一去不复还了,呜呜.话说面试了几个公司,真心没准备好就上了,结果当然是小悲催.还好有容身之处,就算是搬砖,也有可能为自己盖楼,吼吼. 好,下面我来分享一道有意思的面试题,说他有意思,是因 ...

  7. C#程序员整理的Unity 3D笔记(十):Unity3D的位移、旋转的3D数学模型

    遇到一个想做的功能,但是实现不了,核心原因是因为对U3D的3D数学概念没有灵活吃透.故再次系统学习之—第三次学习3D数学. 本次,希望实现的功能很简单: 如在小地图中,希望可以动态画出Player当前 ...

  8. 【转】Unity 相关经典博客资源总结(持续更新)

    原文:http://blog.csdn.net/prothi/article/details/20123319 就作为一个记录吧,把平时看过的Unity相关的一些好的Blog记录并分享. 好的论坛: ...

  9. Unity 触屏缩放模型

    现在的手机都是触屏控制的,那么在游戏中我们想通过手指在屏幕上滑动捕获相应的动作呢?Unity官网API中提供了Input类和Touch类,在该类里提供了许多接口.相信只要我们稍微看下,就可以自己应用了 ...

随机推荐

  1. git 拉取远程指定分支 pull本地不存在的分支

    默认,git项目只有一个分支,就是master,我们当然可以在本地创建多个分支,并推送到远程git管理平台上,或者将远程git管理平台上的其他分支拉取到自己电脑上. 一.查看本地已有的分支 进入到项目 ...

  2. 一幅图秒懂LoadAverage(负载)

    转自:http://www.habadog.com/2015/02/27/what-is-load-average/ 一幅图秒懂LoadAverage(负载)   一.什么是Load Average? ...

  3. epoll的两种工作模式

    epoll有两种模式,Edge Triggered(简称ET) 和 Level Triggered(简称LT).在採用这两种模式时要注意的是,假设採用ET模式,那么仅当状态发生变化时才会通知,而採用L ...

  4. 聚类:层次聚类、基于划分的聚类(k-means)、基于密度的聚类、基于模型的聚类

    一.层次聚类 1.层次聚类的原理及分类 1)层次法(Hierarchicalmethods)先计算样本之间的距离.每次将距离最近的点合并到同一个类.然后,再计算类与类之间的距离,将距离最近的类合并为一 ...

  5. ASP.NET MVC:UrlHelper.cs

    ylbtech-funcation-Utility: ASP.NET MVC:UrlHelper.cs 充当表示 ASP.NET Razor 页的类的基类. 1.UrlHelper 类返回顶部 1-1 ...

  6. go语言之进阶篇借助bufio实现按行读取内容

    1.借助bufio实现按行读取内容 示例: package main import ( "bufio" "fmt" "io" "o ...

  7. 用Visual C#来清空回收站(1)

    视窗操作系统的回收站是对文件一种保护措施,他主要是作用是不言而喻的.在新的视窗2000系统之中,当我把文件删除到回收站中以后,按动"清空回收站"按钮,想清空回收站,此时往往提示&q ...

  8. python3 中对arrow库的总结(转发)

    https://blog.csdn.net/soft_kind/article/details/80614896 arrow库的官方文档:http://arrow.readthedocs.io/en/ ...

  9. CentOS下ssh sftp配置及权限设置

    运营有异地传输文件的需求,但如果通过QQ等即时通讯软件,不利于文件的集中管理,不方便.而我们办公室的内网机器无法提供外网访问方法,且传输的内容不合适放到公共的网盘或者是云存储上,所以只能用线上负载较低 ...

  10. dubbo Framework pic

    dubbo Framework pic