https://github.com/unity-technologies/conditionalcompilationutility
Automatically add defines upon the detection of predicate classes
https://github.com/unity-technologies/conditionalcompilationutility
unity unity-editor
Last synced: 6 months ago
JSON representation
Automatically add defines upon the detection of predicate classes
- Host: GitHub
- URL: https://github.com/unity-technologies/conditionalcompilationutility
- Owner: Unity-Technologies
- License: other
- Created: 2018-01-10T00:21:20.000Z (about 8 years ago)
- Default Branch: master
- Last Pushed: 2023-02-08T22:48:34.000Z (about 3 years ago)
- Last Synced: 2025-04-05T05:33:31.850Z (10 months ago)
- Topics: unity, unity-editor
- Language: C#
- Homepage:
- Size: 9.77 KB
- Stars: 125
- Watchers: 7
- Forks: 15
- Open Issues: 4
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# ConditionalCompilationUtility
The Conditional Compilation Utility (CCU) will add defines to the build settings once dependendent classes have been detected.
A goal of the CCU was to not require the CCU itself for other libraries to specify optional dependencies. So, it relies on
the specification of at least one custom attribute in a project that makes use of it. Here is an example:
```
[Conditional(UNITY_CCU)] // | This is necessary for CCU to pick up the right attributes
public class OptionalDependencyAttribute : Attribute // | Must derive from System.Attribute
{
public string dependentClass; // | Required field specifying the fully qualified dependent class
public string define; // | Required field specifying the define to add
}
```
Then, simply specify the assembly attribute(s) you created in any of your C# files:
```
[assembly: OptionalDependency("UnityEngine.InputNew.InputSystem", "USE_NEW_INPUT")]
[assembly: OptionalDependency("Valve.VR.IVRSystem", "ENABLE_STEAMVR_INPUT")]
namespace Foo
{
...
}
```
This allows a separate project on GitHub, for example, to define optional dependencies independently. And if CCU is present, then
the defines will automatically be added upon detection of dependent classes. If the CCU is not present, then the project would
still work, but may require the developer to add defines manually.