Package Manager Injection Helper
A set of classes that allow you to inject your own code into the Package Manager Window
net.tnrd.packagemanagerinjection 
Install via UPM
Add to Unity Package Manager using this URL
https://www.pkglnk.dev/packagemanagerinjection.git README Markdown
Copy this to your project's README.md
## Installation
Add **Package Manager Injection Helper** to your Unity project via Package Manager:
1. Open **Window > Package Manager**
2. Click **+** > **Add package from git URL**
3. Enter:
```
https://www.pkglnk.dev/packagemanagerinjection.git
```
[](https://www.pkglnk.dev/pkg/packagemanagerinjection)Dependencies (3)
Used By (1)
README
Package Manager Injection Helper
A set of classes that allow you to inject your own code into the Package Manager Window
Installation
- The package is available on the openupm registry. You can install it via openupm-cli.
openupm add net.tnrd.packagemanagerinjection
- Installing through a Unity Package created by the Package Installer Creator from Needle
Usage
The PackageManagerInjectionHelper injects a visual element into the Package Manager Window through an IPackageManagerExtension. This is done through a [InitializeOnLoadMethod].
You can access the injected visual element through the PackageManagerInjectionHelper like so
public class Foo
{
[InitializeOnLoadMethod]
private static void Init()
{
PackageManagerInjectionHelper.Injected += OnVisualElementInjected;
}
private static void OnVisualElementInjected()
{
InjectedVisualElement element = PackageManagerInjectionHelper.InjectedVisualElement;
}
}
Note that there's an event to subscribe to. The Injected event is required because the visual element that gets injected might not get injected immediately after recompiling your code.
You can always access the element through PackageManagerInjectionHelper.InjectedVisualElement. Just keep in mind that it might not be ready yet and use the event properly.
Once you have access to the element you receive access to a number of items in the Package Manager Window
| Name | Description |
|---|---|
| Root | The root visual element of the Package Manager Window. You should be able to access all child visual elements through here. |
| PackageManagerToolbar | The Package Manager Toolbar is the toolbar that resides at the top of the Package Manager Window. |
| PackageList | The Package List is the list on the left side of the window that contains package groups and package items. |
| PackageStatusBar | The Package Status Bar is the bar on the bottom left of the window. This is where the refresh button resides. |
| PackageDetails | The Package Details is the right part of the window that contains all the detailed information of the selected package. |
| PackageToolbar | The Package Toolbar is the toolbar on the bottom right. Here you'll find buttons like download, install, and remove. |
Each of these items gives you access to a specific part of the Package Manager Window. However, all of these are automatically generated and based on reflection. Therefore there is no guarantee that this package will work across all versions of Unity.
Therefore I encourage people to submit issues whenever they find incompatibilities with a specific version, allowing me to generate a new set of classes for that specific version of Unity.
Support
Package Manager Injection Helper is a small and open-source utility that I hope helps other people. It is by no means necessary but if you feel generous you can support me by donating.
Contributing
Pull requests are welcomed. Please feel free to fix any issues you find, or add new features.
No comments yet. Be the first!