高度な機能の使い方
Androidの設定¶
Herculesの追加機能を使用するには、Android Gradleモジュールでprefab機能が有効になっている必要があります。
Android Studioプロジェクトの設定¶
-
Android Gradle Plugin 4.1未満使用時
-
gradle.propertiesファイルに以下のように追加します。
-
-
Android Gradle プラグイン 4.1 以上を使用する場合
-
build.gradle ファイルにある android ブロックに以下のように追加します。
-
-
モジュールレベルの build.gradle ファイルに、
dependenciesセクションに以下のライブラリを追加します:
CMake / ndk-build 設定 (C/C++ 使用のため)¶
-
NDK r21 以上を使用する場合
// CMakeを使用する場合 find_package(Hercules REQUIRED CONFIG) target_link_libraries( ... Hercules::Hercules ) // Android.mkを使用する場合 LOCAL_SHARED_LIBRARIES := Hercules include $(BUILD_SHARED_LIBRARY) ifneq ($(call ndk-major-at-least,21),true) $(call import-add-path,$(NDK_GRADLE_INJECTED_IMPORT_PATH)) endif $(call import-module, prefab/Hercules) -
NDK r21以下を使用する場合
-
Hercules.hファイルをプロジェクトに別途追加し、.soファイルのパスを指定して直接リンクします。
// CMakeを使用する場合 target_link_libraries( ... ${CMAKE_CURRENT_SOURCE_DIR}/../build/intermediates/merged_native_libs/${CMAKE_BUILD_TYPE}/out/lib/${ANDROID_ABI}/libHercules.so ) // Android.mkを使用する場合 include $(CLEAR_VARS) LOCAL_MODULE := Hercules LOCAL_SRC_FILES := ../build/intermediates/merged_native_libs/release/out/lib/$(TARGET_ARCH_ABI)/libHercules.so include $(PREBUILT_SHARED_LIBRARY) LOCAL_SHARED_LIBRARIES := Hercules
-
iOSの設定¶
設定方法¶
- CocoaPodsを通じてプロジェクトにインストールされたHerculesフレームワークのパス以下で.hを見つけてプロジェクトにimportします。
シミュレーターまたはデバイスターゲットパスに含まれているヘッダーの中から何でも選んで使用しても問題ありません。
パスは次の通りです。
Unityを設定する¶
プロジェクト設定を行う¶
-
Add USE_HERCULES to Unity's preprocessor flags.
- Player Settings → Other Settings → Script Compilation → Scripting Define Symbols
-
Checks to allow 'unsafe' code.
- Player Settings → Other Settings → Script Compilation → Allow 'unsafe' code
Unreal 設定¶
SDK Unreal Plugin に含まれている Hercules モジュールは、Hercules の追加機能をサポートしていません。
Unreal 環境で Hercules の追加機能を使用する場合は、以下を参照してください。
- HiveSDK UE Plugin に含まれている Hercules モジュールを削除
-
HiveSDK UE Plugin 上部にある HerculesPlugin を使用するよう設定(Build.cs で使用するプラットフォームに応じて選択)
if (Target.Platform == UnrealTargetPlatform.Android) PrivateDependencyModuleNames.AddRange(new string[] { "HerculesPlugin" }); if (Target.Platform == UnrealTargetPlatform.IOS) PrivateDependencyModuleNames.AddRange(new string[] { "HerculesPlugin" }); if (Target.Platform == UnrealTargetPlatform.Win64) PrivateDependencyModuleNames.AddRange(new string[] { "HerculesPlugin" }); -
HiveSDK UE Plugin に含まれる HerculesPlugin を使用する場合、主要な関数を直接呼び出す必要があります。
#include "HerculesPlugin.h" // HiveConsole で発行された game_id と app_id の値を使用します。 #if PLATFORM_WINDOWS CHerculesPlugin::Initialize(game_id, 0, app_id, app_version); #else CHerculesPlugin::Initialize(game_id, 0); #endif // Hive Device ID が発行されたら設定します。 ::HerculesSetDeviceId(TCHAR_TO_UTF8(*deviceId)); // ユーザーがログインしたときに Player ID を設定し、再ログイン時にも再度設定します。 ::HerculesSetPlayerId(TCHAR_TO_UTF8(*playerId));

