Version: 2020.2
言語: 日本語
パッケージアセットへのアクセス
解決と競合

スコープ付きパッケージレジストリ

A scoped registry allows you to use a custom registry where you can host your own packages, in addition to the Unity registry. This is the same concept that npm uses. Using scoped registries ensures that the Package Manager always maps a package to one and only one registry, guaranteeing a consistent result regardless of network conditions.

組織によっては、クローズドネットワーク (閉域網) の中で仕事をしているために、Unity 自体のパッケージレジストリにアクセスすることが困難な場合があります。このような場合、その組織は、クローズドネットワーク内のサーバーに独自のパッケージレジストリを設定することができます。ネットワーク管理者は、Unity のパッケージレジストリと定期的に同期して、スコープ付きレジストリに最新のパッケージがあることを確認します。

In some cases, developers want to provide their own custom modifications to standard Unity packages to their customers in a single, reliable location. Examples of these include creating custom toolbar or menu items for a Unity package, or extending the tools provided in a Unity package to interface better with their own custom package.

Custom package providers put their custom Unity packages on a package registry server. A package registry server is an application that keeps track of packages and provides a place to store them. A scoped registry communicates the location of the custom package registry server to Unity so that the user has a seamless experience where the custom package overrides the Unity package without the user having to manually install the set of custom packages.

This document explains how a package consumer can set up their Unity project to use an existing custom package registry server. If you are a package producer, see Sharing your package to find out which package registry servers are supported and links to information on how to set them up to use with scoped registries.

ノート: アクセスが制限されているパッケージレジストリサーバーを指すスコープ付きレジストリを設定する場合、Package Manager が npm 認証トークンをサーバーに渡すように設定できます。詳細は、スコープ付きレジストリの認証 を参照してください。

スコープ付きレジストリの設定

To set up your scoped registries in your project manifest, use the scopedRegistries property, which takes an array of scoped registry configuration objects. Each object contains a name, a url location, and a list of scopes for each package name pattern you want to map to that scoped registry:

プロパティ JSON 型 説明 
name 文字列 The scope name as it appears in the user interface. The Package Manager window displays this name in the package details view. For example, "name": "Tools".
url 文字列 The URL to the npm-compatible registry. For example, "url": "https://mycompany.example.com/tools-registry"
scopes 文字列の配列 Array of scopes that you can map to a package name, either as an exact match on the package name, or as a namespace.

For example, "scopes": [ "com.example", "com.example.tools.physics" ]

Note: This type of configuration assumes that packages follow the Reverse domain name notation. This ensures that com.unity is equivalent to com.unity.*.

Package Manager が、どのレジストリからパッケージを取得するかを決定するとき。パッケージの namescopes の値を比較して、scopes が最もよくマッチするレジストリを見つけます。

For example, in the project manifest below, there are two scoped registries, “Main” and “Tools”:

{
    "scopedRegistries": [
        {
            "name": "Main",
            "url": "https://example.com/registry",
            "scopes": [
                "com.example", "com.example.tools.physics"
            ]
        },
        {
            "name": "Tools",
            "url": "https://mycompany.example.com/tools-registry",
            "scopes": [
                "com.example.mycompany.tools"
            ]
        }
    ],
    "dependencies": {
        "com.unity.animation": "1.0.0",
        "com.example.mycompany.tools.animation": "1.0.0",
        "com.example.tools.physics": "1.0.0",
        "com.example.animation": "1.0.0"
    }
}

When the Package Manager looks up the com.example.animation package, it finds that the com.example.* namespace is the closest match to its name, and therefore fetches the package from the “Main” registry.

When the Package Manager looks up the com.example.tools.physics package, the “Tools” registry has a scope that exactly matches the package name.

When the Package Manager looks up the com.example.mycompany.tools.animation package, the Package Manager finds that the com.example.mycompany.tools.* namespace is the closest match to its name and therefore fetches the package from the “Tools” registry. Even though it also matches the “Main” scope, the com.example.* namespace is not as close a match.

Package Manager が com.unity.animation パッケージを検索すると、スコープ付きレジストリのどれにもマッチしないため、デフォルトのレジストリからパッケージを取得します。


パッケージアセットへのアクセス
解決と競合