How to Add global #define directive to Unity Packages?

Hi.

I am developing many Unity packages and they depend on each other.

I need to add global #define directive to each of my packages.

Also, i want to others to develop plugins for my packages, and they need to run code if the desired package is exists.

for example i want to add #define BAYATGAMES directive to all of my packages. and when the user imports the package the directive should be available as global in all scripts.

How can i achieve this?

In editor scripting you can use Unity - Scripting API: PlayerSettings.SetScriptingDefineSymbolsForGroup to set defines for the whole project but I don’t think you can import #defines from packages.

You could import the package manually using AssetDatabase.importPackage and then set the defines. Alternatively I think you could write an editor script that hooks into this callback: Unity - Scripting API: AssetDatabase.importPackageCompleted and then set the define when it’s complete?

I need to add the #define directive to a package not to my own project.

So how do i hook into https://docs.unity3d.com/ScriptReference/AssetDatabase-importPackageCompleted.html

Thanks for the reply.