I have been working on a custom camera plugin that was originally designed to make it work with older unity inputs and default camera. I am currently redesigning it a bit to make it compatible with modern solutions like new Input System and Cinemachine.
I will try to support both legacy and modern versions. I have worked out how to define custom directives to check if package (or its version) is installed or not.
I would like to know if there is a way to prompt for installation of specific package, from the editor. Ideally there should be a button in the inspector window that when clicked would open a prompt listing missing dependencies giving user option to automatically download them.
Is that achievable?
Check the Package Manager API. It may or may not be supported. But you could write a script that updates the manifest.json. But it better be foolproof otherwise you could easily aggravate users.
Free advice: if you haven‘t published that tool yet, go all in with Cinemachine and Input System. You‘ll save yourself a lot of trouble and likely end up with a better tool by building on top of better features.
I would not recommend manually modifying the manifest.json file. Unity has this API to install packages from code:
Great answers from @CodeSmile and @KyryloKuzyk !
I also recommend against modifying the project manifest file directly. Using the Package Manager API is the way to go. You can use the Client.Add method, as suggested by @KyryloKuzyk , but if you have multiple dependencies to add, check out Unity - Scripting API: PackageManager.Client.AddAndRemove which supports batch additions. It’s available in 2021.2 and newer versions.
1 Like