ShareREC下载地址:http://rec.mob.com/download
根据自己需求下载版本,笔者在这里讲的是ShareREC for android_unity3d
快速集成
1、下载最新版本ShareREC for Unity3D的SDK,解压以后可以找到ShareREC的unitypackage。
2、双击之并将其中的文件导入您的项目。
3、进入目录plugin/ShareRec,选择其中的ShareRec脚本,将它拖到游戏的MainCamera下,并填写上您的AppKey、AppSecret,并进行一些基本的配置,如下图所示
具体参数参照官方文档:http://wiki.mob.com/sharerec-for-android-unity3d-%e5%bf%ab%e9%80%9f%e9%9b%86%e6%88%90/
添加自己的脚本在主像机上(加了一个按钮控制开始录制和结束录制并分享)
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
using cn.sharerec;
public class TestRec : MonoBehaviour
{
bool IsRecording = false;
public Button Start_BTU;
void Start()
{
Start_BTU.onClick.AddListener(OnBtnStart);
}
public void OnBtnStart()
{
if (ShareREC.IsAvailable())
{
if (!IsRecording)
{
OnStartRecode();
}
else
{
OnStopRecode();
}
}
}
//开始录制
void OnStartRecode()
{
ShareREC.StartRecorder();
IsRecording = true;
}
//停止录制
void OnStopRecode()
{
//停止监听事件
ShareREC.OnRecorderStoppedHandler = OnShowShare;
//停止录制
ShareREC.StopRecorder();
IsRecording = false;
}
//当停止的时候分享
void OnShowShare()
{
// 停止录制后启动分享视频 (show sharing page after the recorder is stopped)
ShareREC.SetText("Angry Rebot");
ShareREC.AddCustomAttr("score", "5000");
ShareREC.AddCustomAttr("name", "ShareREC Developer");
ShareREC.AddCustomAttr("brand", "hehe!");
ShareREC.AddCustomAttr("level", "10");
ShareREC.AddCustomPlatform("CustomPlatform");
ShareREC.ShowShare();
}
}
你以为这样就完事了?
大坑来了(加粗加大)
找到导入工程中的Plugins/Android/ShareRec 下的AndroidManifest.xml文件(妈的放的还挺深)
加上自己的Appkey和Value----- http://dashboard.mob.com/#!/index 在这儿添加应用获得键值对
<application>
<activity
android:name="com.mob.tools.MobUIShell"
android:configChanges="keyboardHidden|orientation|screenSize"
android:theme="@android:style/Theme.Translucent.NoTitleBar"
android:windowSoftInputMode="stateHidden|adjustResize" />
//加上这两句
<meta-data android:name="Mob-AppKey" android:value="自己的Appkey"/>
<meta-data android:name="Mob-AppSecret" android:value="自己的AppValue"/>
</application>
打包前打开Player Settings设置一下
到这里应该没什么问题了,还有什么问题可以联系Mob客服,也会很认真的帮忙解决
第一次发博客,如有不足,望各位大佬请多多指教。