Version: 2019.2
ローカルパス
スコープ付きパッケージレジストリ

Git URL

When the Package Manager fetches a package from a Git repository, it adds the package locally to your Project. This allows you to easily test unpublished changes, but you cannot use it to contribute to that Git repository. To set up an existing local Git repository as a dependency in your Project, use a local path instead.

To use Git packages in a Project, make sure the Git client is installed on your machine and that you have added the Git executable path to the PATH system environment variable.

リポジトリが Git LFS でファイルを追跡する場合は、Git LFS クライアントもマシンにインストールされていることを確認してください。インストールされていないと、Package Manager は LFS サーバーに保存されたファイルを取得できず、エラーメッセージや警告メッセージなしに LFS ポインターファイルをチェックアウトします。

Note: You cannot use the Package Manager window to install a package directly from a Git repository. You must edit the Project manifest to add a Git URLs as a dependency.

依存関係として Git URL を指定するには、バージョン番号やローカルファイルパスの代わりに Git URL を使用してインストールするパッケージの名前を加えます。例えば、以下は推奨される HTTPS プロトコルを使用してリモート Git を指定する方法を示しています。

{
  "dependencies": {
    "com.mycompany.mypackage": "https://mycompany.github.com/gitproject/com.mycompany.mypackage.git"
}

Package Manager は、httpshttpsshgitfile プロトコルを以下の形式でサポートします。

  <protocol>://[<user>[:<password>]@]<host>[:<port>]/<path>.git[#<revision>]

これらの形式で URL が git で始まる場合は、.git パスサフィックスを省くこともできます。

  git://[<user>[:<password>]@]<host>[:<port>]/<path>[#<revision>]

または

  git+<protocol>://[<user>[:<password>]@]<host>[:<port>]/<path>[#<revision>]

You might need to configure credentials in Git configuration files in order to provide your username and password securely. This is preferable to hard-coding them in the Git URL, which is a major security issue if the Project is shared with others.

SSH を使用して認証する場合、Git はデフォルトの場所にあるキーを使用します。ただし、 PuTTY を Windows の SSH クライアントとして使用する場合は、GIT_SSH 環境変数を設定して plink.exe を指すようにする必要があります。

SSH キーは Unity の外部で設定する必要があります。適切なアクセス権がない場合は、エディターが認証の失敗を通知します。

特定のホストの認証の設定に関する詳細は、GitLabGitHub のヘルプページを参照してください。

特定のリビジョンをターゲットにする

インストールするリビジョンを指定できます。リビジョンは、最終的に Git のコミットハッシュに解決される式です。最も一般的なリビジョンのタイプは、コミットハッシュ、タグ、ブランチです。

特定のリビジョンをターゲットにするには、dependencies 属性の Git URL に # とリビジョン (バージョン または特定の Git ハッシュ)を追加します。 ハッシュを指定することで、必要なバージョンを正確に取得できます。以下はその例です。

{
  "dependencies": {
    "com.mycompany.mypackage": "https://mycompany.github.com/gitproject/com.mycompany.mypackage.git#523c4f291cea796141e7211f4951702984d2e9ca"
  }
}

リビジョンを省略すると、Package Manager はリモートリポジトリの HEAD リビジョンを使用します。

適切なリビジョンの設定に関する詳細は、Git リビジョンの Git のユーザー セクションを参照してください。

SSH プロトコルの使用

If you want to use the ssh protocol, make sure you use the full protocol syntax. The Package Manager does not support SCP-based shorthand syntax, and many Git hosting services supply the repository’s URL with the SCP syntax. So if you are copying the URL directly, make sure you use the ssh:// protocol and replace the colon (:) before the repository path with a slash (/). For example, if you get git@mycompany.github.com:gitproject/com.mycompany.mypackage.git from a GitHub repository, make sure you change it to the full syntax, as shown in this example:

{
  "dependencies": {
    "com.mycompany.mypackage": "ssh://git@mycompany.github.com/gitproject/com.mycompany.mypackage.git"
}

NOTE: If you set up your SSH key with a passphrase, the Package Manager can’t retrieve the package, because you need to enter the passphrase in a shell or command line. In this case, consider using the https protocol instead, or use the ssh-add utility shipped with Git. For more information, see Authentication issues with Git URLs.

FILE プロトコルの使用

The Package Manager does not support file paths with the file prefix, but it does support full URLs with the file protocol. For example:

{
  "dependencies": {
    "com.mycompany.mypackageA": "file://localhost/absolute/path/to/com.mycompany.mypackageA.git",
    "com.mycompany.mypackageB": "file:///absolute/path/to/other/com.mycompany.mypackageB.git"
  }
}
ローカルパス
スコープ付きパッケージレジストリ