1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

UnityFrameworkが提供している各クラスの主要メソッド一覧(Objective-C)

Last updated at Posted at 2026-01-03

Unity as a Library×Swiftの記事はシリーズになっています。
記事を順番に読み進めると、Unity as a LibraryをSwiftで使えるようになります。

はじめに

本記事は どすこい塾 Advent Calendar 2025 の16日目の記事です。
昨日も @uhooiUnity as a LibraryのXCFrameworkを生成するGitHub Actions でした。

UnityFramework.framework が提供している各クラスの主要メソッドとプロパティを紹介します。
Objective-Cで実装されていますが、Swiftから呼び出せます。

環境

  • OS:macOS Sequoia 15.6(24G84)

UnityFrameworkクラスが提供している主要メソッド一覧

UnityFramework クラスが提供している主要なメソッドを紹介します。

メソッド 説明
+ (UnityFramework*)getInstance; UnityFramework クラスのシングルトンのインスタンスを返す
- (UnityAppController*)appController; UnityAppController クラスのインスタンスを返す。実行されていない場合は nil を返す
- (void)setExecuteHeader:(const MachHeader*)header; ヘッダーをセットする
- (void)registerFrameworkListener:(id<UnityFrameworkListener>)obj; UnityFrameworkListener を登録する
- (void)unregisterFrameworkListener:(id<UnityFrameworkListener>)obj; UnityFrameworkListener の登録を解除する
- (void)setDataBundleId:(const char*)bundleId; Unityランタイムが Data フォルダを探すためのバンドルIDをセットする
- (void)runUIApplicationMainWithArgc:(int)argc argv:(char*[])argv; Unityを実行する(他のビューが存在しない場合)
- (void)runEmbeddedWithArgc:(int)argc argv:(char*[])argv appLaunchOpts:(NSDictionary*)appLaunchOpts; Unityを実行する(他のビューが存在する場合)
- (void)pause:(bool)pause; Unityを一時停止する
- (void)unloadApplication; Unityをアンロード(終了)する。Unityを再実行できる
- (void)quitApplication:(int)exitCode; Unityをクィット(完全にアンロード)する。Unityを再実行できない
- (void)showUnityWindow; 実行中のUnityウィンドウを表示する

UnityAppControllerクラスが提供している主要プロパティ一覧

UnityAppController クラスが提供している主要なプロパティを紹介します。

プロパティ 説明
@property (retain, nonatomic) UIWindow* window; ウィンドウ。Unityビューを他のウィンドウで使う場合は isHiddentrue にする
@property (readonly, copy, nonatomic) UIView* rootView; ルートビュー。ビューをUnityウィンドウ以外のウィンドウで使う場合に呼ぶ

UnityFrameworkListenerプロトコルが提供しているメソッド一覧

UnityFrameworkListener プロトコルが提供しているデリゲートメソッドを紹介します。

それぞれ後処理を実行する場合に中身を実装します。

メソッド 説明
- (void)unityDidUnload:(NSNotification*)notification; Unityのアンロード後に呼ばれる
- (void)unityDidQuit:(NSNotification*)notification; Unityのクィット後に呼ばれる

おわりに

これらのメソッドやプロパティが一通りわかると、iOSでUnityを実行できます。

以上 どすこい塾 Advent Calendar 2025 の16日目の記事でした。
明日も @uhooi です。

参考リンク

1
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?