0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

【VRChat】VPM対応のすゝめ

Last updated at Posted at 2025-03-03

はじめに

VPM、便利ですよね。+ボタンをポチッと押すだけで簡単にインストールできます。
VPMはVRChat Package Managerの略で、VRChat Creator Companion(VCC)やALCOMがその機能を担ってくれます。パッケージの更新もボタン一つで出来る革命的な機能です。
この記事では、作成したアセットをVPM対応させるための方法を解説します。

※2025/03時点の情報です。
※この記事は一例であり、対応を保証するものではなく、筆者は一切の責任を負いかねます。

前提

この記事では、Assets/Test下にTest.csを置き、これをVPM対応させます。適宜読み替えてください。
image.png
Start時に「Hello, World!」するだけのU#です。
image.png

VPM対応

必ずバックアップしてから始めてください!

Unity

アセットをパッケージ化

Package Makerを開きます。
image.png
良い感じに設定します。
image.png
Package IDは、自分のドメインがある場合はそれを逆方向に、ない場合は com.[自分の名前].[パッケージ名] などにしておくとよいでしょう。これに沿っていなくても問題ありませんが、他のもの(特に他の人のパッケージ)と被らないように注意してください。
Related VRChat Packageは正しく設定しましょう。設定しないとアバター・ワールド両方に表示されてしまいます。(2敗)
メールアドレスは一応後で消せます。

Convert Assets to Packageしたら、一度Unityのウィンドウを非アクティブにして、再度アクティブにします。 こうすることでUnityがファイル群を認識してくれます。うまくいかなかったら再起動でもOKです。
Packagesフォルダ内に先ほど入力したPackage IDの名前のフォルダがあるので開きます。

README.mdの編集

作成後、README.mdにはPCのユーザー名が製作者として書かれていますので注意してください。

package.jsonの編集

Unity上での設定

Unity上で設定できる部分は設定します。下に雑な設定例を載せておきます。
image.png
ここで設定したバージョンがそのままRelease時のバージョンとなるので、正しく設定しましょう。

テキストエディタ上での設定

localPathや、emailなどはpackage.jsonを直接編集することで消せます。
依存関係のバージョンを設定します。VRChat SDKは後方互換性があると信じているので、「以上」を表す>=を付けます。
以下は設定例です。

package.json
{
  "name": "com.nomlas.test",
  "displayName": "Test Package",
  "version": "0.0.1",
  "description": "Describe this Package",
  "gitDependencies": {},
  "vpmDependencies": {
    "com.vrchat.worlds": ">=3.7.5"
  },
  "author": {
    "name": "nomlas"
  },
  "legacyFolders": {},
  "legacyFiles": {},
  "localPath": "",
  "unity": "2022.3"
}

asmdefの設定

UdonSharp.Runtimeの追加

Runtimeフォルダ内のasmdefに、UdonSharp.Runtimeを追加します。
image.png

U# Assembly Definitionの追加

(これがないと動かないのに自動生成してくれないんですよね...)
Projectタブ上でU# Assembly Definitionを作成し、Source Assemblyにasmdefファイルを指定します。

GitHub

VPM Package Templateをダウンロード

不要なファイルもあるのでZIP形式でダウンロードしてしまいましょう。

gitignoreの更新

大量に追跡対象のファイルがあるので、(あまり良くないですが)雑にこれを足します。

gitignore
/*/
!/Website/
!/Packages/
!/.github/

完了したら、Packagesフォルダ内のgitignoreも編集していきます。
Packagesフォルダ内のgitignoreは、!com.vrchat.core.*を削除し、!com.vrchat.demo-templateを自分のパッケージに変更します。

不要なファイルを削除

必要なのは

  • workflowファイル
  • gitignoreファイル
  • Websiteフォルダ内ファイル
    だけです。他は削除しましょう。
    image.png

出来たらPublicのリポジトリに上げます。

GitHub上での設定

リポジトリ変数の作成

リポジトリ変数を作成します。画像赤枠のボタンをクリックし、NameにPACKAGE_NAME、Valueにcom.nomlas.testなどのパッケージ名を入力します。
image.png

GitHub Actionsの設定

設定ページのまま、「Pages」を選択して、「Source」ドロップダウンを「GitHub Actions」に変更します。

GitHub Pagesの設定

GitHub Actionsによる自動実行に対応するため、「制限なし」にします。
image.png

Action実行

Actionsページで「Build Release」を走らせると自動的にタグが打たれ、リリースされます。さらにその後自動的に「Build Repo Listing」が走り、GitHub Pagesを構成してくれます。
image.png

お疲れさまでした。複数のパッケージを配信するVPM Package Listingの設定方法は以下の記事でまとめています。

カスタマイズ

releaseをドラフトにしたい

release.ymlに以下の設定を追加します。

release.yml
      # Publish the Release to GitHub
      - name: Make Release
        uses: softprops/action-gh-release@de2c0eb89ae2a093876385947365aca7b0e5f844
        with:
+         draft: true
+         generate_release_notes: true
          files: |
            ${{ env.zipFile }}
            ${{ env.unityPackage }}
            ${{ env.packagePath }}/package.json
          tag_name: ${{ env.version }}

ドラフトでもbuild-listing.ymlが実行されてしまうので、実行されないよう編集します。

build-listing.yml
on: 
  workflow_dispatch:
  workflow_run:
    workflows: [Build Release]
    types:
      - completed
  release:
-    types: [published, created, edited, unpublished, deleted, released]
+    types: [published, unpublished, deleted]

トラブルシューティング

workflowが見つからない

.github\workflowsのworkflowファイル群を上げなおすと認識してくれます。

Unity実行時にエラーが出る

以下のエラーの場合

Packages\com.nomlas.test\Runtime\Test.cs(2,7): error CS0246: The type or namespace name 'UdonSharp' could not be found (are you missing a using directive or an assembly reference?)
Packages\com.nomlas.test\Runtime\Test.cs(7,21): error CS0246: The type or namespace name 'UdonSharpBehaviour' could not be found (are you missing a using directive or an assembly reference?)

U# Assembly Definitionの追加をご覧ください。

その他のエラーの場合

アセンブリ定義参照が正しく行われているか確認してください。

0
0
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
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?