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 ポインターファイルをチェックアウトします。
ノート: Package Manager ウィンドウを使用して、Git リポジトリから直接パッケージをインストールすることもできます。詳細は、Git URL からのインストールを参照してください。
依存関係として Git URL を指定するには、バージョン番号やローカルファイルパスの代わりに Git URL を使用してインストールするパッケージの名前を加えます。例えば、以下は推奨される HTTPS プロトコルを使用してリモート Git を指定する方法を示しています。
{
"dependencies": {
"com.mycompany.mypackage": "https://mycompany.github.com/gitproject/com.mycompany.mypackage.git"
}
Package Manager は、https、http、ssh、git、file プロトコルを以下の形式でサポートします。
<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 の外部で設定する必要があります。適切なアクセス権がない場合は、エディターが認証の失敗を通知します。
特定のホストの認証の設定に関する詳細は、GitLab と GitHub のヘルプページを参照してください。
インストールするリビジョンを指定できます。リビジョンは、最終的に 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 プロトコルを使用したい場合は、完全な URL 構文か SCP の短縮形のいずれかを使用できます。
# SCP shorthand
{
"dependencies": {
"com.mycompany.mypackage": "git@mycompany.github.com:gitproject/com.mycompany.mypackage.git"
}
# Full SSH protocol
{
"dependencies": {
"com.mycompany.mypackage": "ssh://git@mycompany.github.com/gitproject/com.mycompany.mypackage.git"
}
ノート: パスフレーズを使って SSH キーを設定した場合、シェルやコマンドラインにパスフレーズを入力する必要があるため、Package Manager はパッケージを取得できません。この場合は、代わりに https プロトコルの使用を検討するか、Git に同梱されている ssh-add ユーティリティーを使用してください。詳細は、Git URL の認証の問題を参照してください。
Package Manager は、file プレフィックスを持つファイルパスを Git URL として認識しませんが、完全な URL が適切にフォーマットされていれば、 file プロトコルを使って Git URL として認識します。以下はその例です。
{
"dependencies": {
"com.mycompany.mypackage1": "file://localhost/absolute/path/to/com.mycompany.mypackage1.git",
"com.mycompany.mypackage2": "git+file:///absolute/path/to/other/com.mycompany.mypackage2"
}
}
Did you find this page useful? Please give it a rating:
Thanks for rating this page!
What kind of problem would you like to report?
Thanks for letting us know! This page has been marked for review based on your feedback.
If you have time, you can provide more information to help us fix the problem faster.
Provide more information
You've told us this page needs code samples. If you'd like to help us further, you could provide a code sample, or tell us about what kind of code sample you'd like to see:
You've told us there are code samples on this page which don't work. If you know how to fix it, or have something better we could use instead, please let us know:
You've told us there is information missing from this page. Please tell us more about what's missing:
You've told us there is incorrect information on this page. If you know what we should change to make it correct, please tell us:
You've told us this page has unclear or confusing information. Please tell us more about what you found unclear or confusing, or let us know how we could make it clearer:
You've told us there is a spelling or grammar error on this page. Please tell us what's wrong:
You've told us this page has a problem. Please tell us more about what's wrong:
Thank you for helping to make the Unity documentation better!
Your feedback has been submitted as a ticket for our documentation team to review.
We are not able to reply to every ticket submitted.