GlitchEnzo / NuGetForUnity

A NuGet Package Manager for Unity
MIT License
3.13k stars 310 forks source link

Define constraints [Suggestion] #639

Open wooolly opened 5 months ago

wooolly commented 5 months ago

Description

I'd like to suggest support for define constraints within the plugins config. At the moment I've gone through and manually set define constraints for each plugin dll, but it'd be great to have a more succinct way of doing this.


p.s. really impressed with this tool, absolute time saver.

JoC0de commented 5 months ago

Hi @wooolly Thanks for the suggestion. I don't understand completely what you mean by define constraints. Do you live kento conditionally included the .dlls into the build, depending un the target platform? Do you need a per-package setting or a per-file? Can you provide a example use case?

wooolly commented 5 months ago

Hi @wooolly Thanks for the suggestion. I don't understand completely what you mean by define constraints. Do you live kento conditionally included the .dlls into the build, depending un the target platform? Do you need a per-package setting or a per-file? Can you provide a example use case?

Hey JoC0de, of course, I'll provide an example :)

image

In the image above I've circled the define constraints option in unity. You can see this option in assembly definitions and plugins, so I've shown the EF Core plugin which I installed using this repo tool. It allows me to include the plugin only in certain builds, in this case I've gone for the DEVELOPMENT_BUILD (but it's just an example). That way, the plugin won't be imported for release builds, only development builds. But it can apply to any custom define constraints added to Unity (which can be set by going to Project Settings -> Player -> Other Settings -> Script Compilation)

image

It's a great way of controlling which plugins are included in certain builds. I'm making a multiplayer game and I only want EF Core included with the server, therefore I'll be using a UNITY_SERVER constraint. I think it'd be most useful in the packages.config file with a new attribute for specifiying define constraints, like you've done with autoReferenced.

I hope this is clear, thank you.