I have my own folder with all the custom .cginc files.
How can I set up Unity to scan this folder for the required cginc files when the shader compiled?
E.g., I have:
Assets/MyCgLib folder
files in this folder: my1.cginc, my2.cginc, my3.cginc …
The following line in my shader:
#include "my2.cginc"
For now, Unity looks for that file only in 2 folders:
./ (current directory)
Unity/Editor/Data/CGIncludes/ (default directory)
How can I add some directories in this list and tell Unity to scan them in this order?
./ (current directory)
Assets/MyCgLib (my folder)
Unity/Editor/Data/CGIncludes/ (default directory)
Of course, I’ve got more then one “my” folder. And of course, cginc files themselves can also contain include statements.
I don’t know how to set a default directory to scan for include files, but they don’t have to be contained in one of the folders you mention - you can place them anywhere in your project and include an absolute/relative directory path in the #include directive itself:
If you sell stuff on the asset store PLEASE don’t use absolute paths. You force people to use your folder layout if you do that, that makes project setup a headache.
If you put your .cginc files right in the project folder (beside the “Assets” folder) you won’t need to specify any paths, similar to how UnityCG.cginc works.
Also you can override UnityCG.cginc by placing a file with the same name beside your “Assets” folder.