Android/iOSで、様々なアプリと連携を行いゲームスコアなどをシェアするプラグイン。
注意:
SocialConnector.Share("Social Connector", "https://github.com/anchan828/social-connector", imagePath);
See Assets/Plugins/SocialConnector/Sample/Sample.cs
using UnityEngine;
namespace SocialConnector
{
public class Sample : MonoBehaviour
{
string imagePath {
get {
return Application.persistentDataPath + "/image.png";
}
}
void OnGUI ()
{
if (GUILayout.Button ("<size=30><b>Take</b></size>", GUILayout.Height (60))) {
Application.CaptureScreenshot ("image.png");
}
GUILayout.Space (60);
///=================
/// Share
///=================
if (GUILayout.Button ("<size=30><b>Share</b></size>", GUILayout.Height (60))) {
SocialConnector.Share ("Social Connector", "https://github.com/anchan828/social-connector", null);
}
if (GUILayout.Button ("<size=30><b>Share Image</b></size>", GUILayout.Height (60))) {
SocialConnector.Share ("Social Connector", "https://github.com/anchan828/social-connector", imagePath);
}
}
}
}
Android API Level 24 から、画像のシェアにおいて FileProvider の使用が必須となりました。このため、プロジェクト単位で AndroidManifest.xml
をカスタマイズしなければいけません。
実装例としてSocialConnector/Plugins/Android
フォルダー配下にAndroidManifest.xml
を配置しています。
以下の手順に沿うことで、FileProviderに対応することが可能です。
SocialConnector/Plugins/Android
フォルダーをPlugins/Android
フォルダーに移動する
AndroidManifest.xml
内のcom.kyusyukeigo.socialconnector.fileprovider
をプロジェクトのパッケージ名に書き換える。(例: パッケージ名がcom.example.game
であれば com.example.game.fileprovider
に書き換える)
Identification
やApplication.identifier
で確認することができます。
もし、何かしらのエラーが起きた場合 support-core-utils-25.3.1.aar
を削除してみてください。ライブラリの競合が解決し、ビルドが通るかもしれません。
このプラグインは、次の技術を使用しています。
ACTION_SEND
UIActivityViewController
ACTION_SEND
、UIActivityViewController
は不特定多数のアプリに対してシェアを行うための機能です。特定のアプリに対してのシェアをサポートしているわけではないということに注意してください。
v0.5.0
v0.4.1
v0.4.0
Copyright (C) 2011 Keigo Ando
This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages
arising from the use of this software.
Permission is granted to anyone to use this software for any purpose,
including commercial applications, and to alter it and redistribute it
freely, subject to the following restrictions:
1. The origin of this software must not be misrepresented; you must not
claim that you wrote the original software. If you use this software
in a product, an acknowledgment in the product documentation would be
appreciated but is not required.
2. Altered source versions must be plainly marked as such, and must not be
misrepresented as being the original software.
3. This notice may not be removed or altered from any source distribution.