Unity api
CLI tool for controlling Unity Editor via command line - Play Mode, console logs, tests, scenes, GameObjects and more
npx -y skills add bigdra50/unity-cli --skill unity-apiAssembled from the repository path, not quoted from the project. Check it against their README if it does not work.
What its author says it does
Copied from the file, not written here
Unity API の探索と実行。u api schema で検索、u api call で任意の public static メソッドを呼ぶ。 Use for: "Unity API 呼び出し", "u api call", "schema 検索", "CLI 非対応操作のフォールバック"
The file declares its own license as MIT. That is the author’s claim about this one file, and it is not the same thing as the license GitHub reports for the repository, which is listed with the other numbers below.
SKILL.md
2.6 KB, as published. Nobody here has run it
unity-api
PREREQUISITE:
../unity-shared/SKILL.md(Relay Server 経由で Unity Editor が起動/アクティブであること)skill 経由のコマンドは必ず
-i <instance>を付ける (unity-shared #インスタンス指定)。--offlineオプションのみ Relay 不要 =-i不要。
メソッド検索
u -i <instance> api schema --type AssetDatabase # 型名でフィルタ
u -i <instance> api schema --namespace UnityEditor # 名前空間でフィルタ
u -i <instance> api schema --method Refresh # メソッド名で検索
u api schema --offline --type PlayerSettings # キャッシュから (Relay 不要なので -i 不要)
メソッド呼び出し
u -i <instance> api call UnityEngine.Application get_unityVersion
u -i <instance> api call UnityEditor.AssetDatabase Refresh
u -i <instance> api call UnityEditor.AssetDatabase ImportAsset --params '["Assets/Prefabs/Player.prefab", 0]'
u -i <instance> api call UnityEditor.EditorApplication ExecuteMenuItem --params '["Window/General/Console"]'
よく使うパターン
| 用途 | コマンド |
|---|---|
| プロジェクト設定 | u -i <instance> api call UnityEditor.PlayerSettings get_productName |
| コンパイル状態 | u -i <instance> api call UnityEditor.EditorApplication get_isCompiling |
| アセット存在確認 | u -i <instance> api call UnityEditor.AssetDatabase AssetPathExists --params '["Assets/..."]' |
| フォルダ作成 | u -i <instance> api call UnityEditor.AssetDatabase CreateFolder --params '["Assets", "New"]' |
| メニュー実行 | u -i <instance> api call UnityEditor.EditorApplication ExecuteMenuItem --params '["Tools/..."]' |
制約
- static メソッドのみ
- 引数: プリミティブ, string, enum, プリミティブ配列
- UnityEngine / UnityEditor 名前空間のみ
- [Obsolete] メソッドは除外済み
既存コマンドとの使い分け
既存コマンド (u scene, u build 等) がある操作はそちらを使う。u api は既存コマンドがカバーしない操作のためのフォールバック。