Example problem:
- I have a package “FOO” that implements feature “FOO_A”.
- I have a package “BAR” that implements feature “BAR_B”.
- I have a small bit of code that depends on both FOO_A and BAR_B, to create feature “FOOBAR_C”.
This raises the following problem:
Our company has created literally hundreds of FOOBAR_C code snippets. Some are large enough to justify their own package, but many are not.
But, I would still like to package these smaller FOOBAR_C features. It seems like I have to create a third package, FOOBAR, which depends on the other two. This is cumbersome and leads to exponential package creation. Bleh.
Thus, the feature request:
Feature: Simply including a package in a project would add all scripting define symbols defined in the package.json to the project-wide Script Define Symbols List, implicitly. I could then use this global scripting define symbol to conditionally add this FOOBAR_C code.
Maybe the Inspector could also allow you to TOGGLE those define symbols, with true as the default value.
Thus, rather than having hundreds of packages, I only need optional dependencies and preprocessor directives (e.g. #if
), making FOOBAR_C automatically enabled when those two packages merge.
Adding this new feature to Unity’s example (from here), it would look like this:
{
"name": "com.unity.example",
"version": "1.2.3",
"displayName": "Package Example",
"description": "This is an example package",
"unity": "2019.1",
"unityRelease": "0b5",
"dependencies": {
"com.unity.some-package": "1.0.0",
"com.unity.other-package": "2.0.0"
},
"keywords": [
"keyword1",
"keyword2",
"keyword3"
],
"author": {
"name": "Unity",
"email": "unity@example.com",
"url": "https://www.unity3d.com"
},
"scriptDefines": [
"UNITY_SOMEPACKAGE",
"SOME_CUSTOM_FEATURE_ENABLED",
],
}
Note the new "scriptDefines"
JSON key with an array of values.
You could even automatically generate based on the name.
E.g. com.unity.example
becomes COM_UNITY_EXAMPLE
.
Obviously, this is all possible manually or via our own custom script, but it would be nice to automate. Unity obviously does this under the hood for some internal tools. Thanks!