The ScriptingDefinitions module makes it easier to manage your project scripting definition symbols. Unity allows developers to add their own scripting definition symbols within the PlayerSettings of each platform, but it's all stuffed into a single line. With this module, you can add definition symbols as objects within your project hierarchy.
Within DuskModules, ScriptingDefinitions is used by every module. Without it, automated optional dependencies would all break, causing a lot of compile errors when importing modules into your project. ScriptingDefinitions has no dependencies.
You can create a DefinitionObject within any folder of your project hierarchy the same way you would add a script or folder.
Right click any folder, then select [Create/DuskModules/DefinitionObject].
Upon creation, you should immediately give it a proper name. The name is the definition symbol that will be added to your project.
When the name is set, the symbol is set in the PlayerSettings and your project will recompile.
Removing one is just as easy. Simply delete it from your project, and the symbol is removed from the PlayerSettings before your project recompiles.
If you ever rename a DefinitionObject, or the PlayerSettings mismatch, simply refresh the asset database and it fixes itself.
Some modules have special folders called Mod folders. The code within such folders have a dependency on another module, but only provide extra features on top of those of the base module. It would be a shame if the entire module would be useless and throw compile errors, if only these extra features are unsupported.
The solution is simple; all scripts in the mod folder are part of an assembly which only compiles if a specific scripting definition symbol is present within the project. If it doesn't exist, the whole Mod folder doesn't compile and can be ignored. If the symbol does exist, the contents compile and are accessible.
Every module includes an unique DefinitionObject, ensuring their scripting definition symbol is added to the project. Because of this, all Mod folders with a dependency on that newly added module suddenly start compiling, and become accessible. All without requiring a single interaction from you.
Simply by including other modules, some modules start offering more features.
Every scripting definition symbol should be named in full caps, with only regular ABC characters and underscores.
For example:
UTILITY_COLLECTION
UNITY_EDITOR
UNITY_ANDROID
If your symbol does not match this style, it is automatically converted when it is added to the symbols.
It's best to keep your DefinitionObject names in this same style!
See the Unity Documentation Platform Dependent Compilation page for more information on this topic.
Don't forget to add using DuskModules.ScriptingDefinitions; to any script using the module.