PackageManager に git リポジトリを追加する場合、そのリポジトリに package.json が存在する必要があります
もし、package.json が無い場合は下記エラーで追加することができません
Cannot perform upm operation: Unable to add package [git@github.com:yayorozu/PackageManagerSample.git]: [git@github.com:yayorozu/PackageManagerSample.git] does not point to a valid package repository. No package manifest was found. Verify the repository URL and make sure the package is located in the root folder of the repository. [NotFound].See console for more details
package.json
package.json を作成しリポジトリのルートに配置しましょう
書き方は、公式サイトにあるので、こちらを読んでもらったほうが早いと思います
上記リンクにもありますが、サンプルの package.json は下記になります
{ "name": "com.unity.example", "version": "1.2.3", "displayName": "Package Example", "description": "This is an example package", "unity": "2019.1", "unityRelease": "0b5", "dependencies": { "com.unity.some-package": "1.0.0", "com.unity.other-package": "2.0.0" }, "keywords": [ "keyword1", "keyword2", "keyword3" ], "author": { "name": "Unity", "email": "unity@example.com", "url": "https://www.unity3d.com" } }
dependencies に github のリポジトリを追加する場合はこのように記述します
"dependencies": { "yorozu.sample.package-manager": "git@github.com:yayorozu/PackageManagerSample.git" },
ブランチや バージョンを指定したりする場合は # のあとに特定の記述をすることで指定できます
特定のブランチ | "git@github.com:yayorozu/hoge.git#my-branch" |
特定のバージョン | "git@github.com:yayorozu/hoge.git#v2.0.0" |
コミットハッシュ | "git@github.com:yayorozu/hoge.git#9e72f9d5a6a3dadc38d813d8399e1b0e86781a49" |
追加テスト
PackageManager で追加するようにサンプルリポジトリを作成しました
git url に https://github.com/yayorozu/PackageManagerSample.git
を追加するとリポジトリを追加できます
不明点
複数Version の登録
Unity の公式リポジトリでは 複数 Version を選択することができますが、ブランチを切り替えて package.json の version を書き換えたのですが、複数表示させることができませんでした
Preview の非表示
Preview の指定をしているわけではないのに Preview が表示されていました
※ Sample等の文字が使われているからという可能性はあります