「Unity/画像共有/SocialConnector」の版間の差分
提供: 初心者エンジニアの簡易メモ
(→androidx対応) |
(→組み込み方法) |
||
| 行9: | 行9: | ||
#SocialConnector/Plugins/Android/AndroidManifest.xmlをPlugins/Andoird/AndroidManifest.xmlへ移動 | #SocialConnector/Plugins/Android/AndroidManifest.xmlをPlugins/Andoird/AndroidManifest.xmlへ移動 | ||
#SocialConnector/Plugins/Android/resをPlugins/Andoird/resへ移動 | #SocialConnector/Plugins/Android/resをPlugins/Andoird/resへ移動 | ||
| + | #以下のように呼び出し。 | ||
| + | |||
| + | string imagePath = Application.persistentDataPath + "/image.png"; | ||
| + | SocialConnector.SocialConnector.Share(message, "https://github.com/anchan828/social-connector", imagePath); | ||
==androidx対応== | ==androidx対応== | ||
2020年3月1日 (日) 07:19時点における版
SocialConnectorとは
unityから共有できるライブラリ
公式
https://github.com/anchan828/social-connector
組み込み方法
- SocialConnector.unitypackage をAssets/Import/CustomImportを選択
- SocialConnector/Plugins/Android/AndroidManifest.xmlをPlugins/Andoird/AndroidManifest.xmlへ移動
- SocialConnector/Plugins/Android/resをPlugins/Andoird/resへ移動
- 以下のように呼び出し。
string imagePath = Application.persistentDataPath + "/image.png"; SocialConnector.SocialConnector.Share(message, "https://github.com/anchan828/social-connector", imagePath);
androidx対応
以下ファイルのandroid.support.v4.content.fileproviderからandroidx.core.content.FileProviderへ置換
AndroidManifest.xml
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
<application android:theme="@style/UnityThemeSelector" android:icon="@drawable/app_icon" android:label="@string/app_name">
<activity android:label="@string/app_name" android:name="com.unity3d.player.UnityPlayerActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
<category android:name="android.intent.category.LEANBACK_LAUNCHER" />
</intent-filter>
<meta-data android:name="unityplayer.UnityActivity" android:value="true" />
</activity>
<provider android:name="androidx.core.content.FileProvider" android:authorities="${applicationId}.fileprovider" android:enabled="true" android:exported="false" android:grantUriPermissions="true">
<meta-data android:name="android.support.FILE_PROVIDER_PATHS" android:resource="@xml/filepaths" />
</provider>
</application>
</manifest>
SocialConnector/SocialConnector.cs
var fileProvider = new AndroidJavaClass("androidx.core.content.FileProvider");
ios対応
以下エラーが出る場合
'autorelease' is unavailable: not available in automatic reference counting mode
Build Phases/Compile SourcesのSocialConnector.mmをダブルクリックして -fno-objc-arc を追加
参考
http://nn-hokuson.hatenablog.com/entry/2018/05/16/195527
