Unclaimed Package Is this your package? Claim it to unlock full analytics and manage your listing.
Claim This Package

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

Style
Preview
pkglnk installs badge
## 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
```

[![pkglnk](https://www.pkglnk.dev/badge/packagemanagerinjection.svg?style=pkglnk)](https://www.pkglnk.dev/pkg/packagemanagerinjection)

Dependencies (3)

Used By (1)

README

Package Manager Injection Helper

GitHub package.json version GitHub issues GitHub pull requests GitHub license GitHub last commit

A set of classes that allow you to inject your own code into the Package Manager Window

Installation

  1. The package is available on the openupm registry. You can install it via openupm-cli.
openupm add net.tnrd.packagemanagerinjection
  1. 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.

ko-fi

Contributing

Pull requests are welcomed. Please feel free to fix any issues you find, or add new features.

Comments

No comments yet. Be the first!