- Home /
Is it possible to make a global cginclude inside of the asset directory?
I've been toying around with this and discovered that:
absolute and relative paths are supported for cgincludes-- You can write things like #include "Assets/cgincludes/mycginclude.cginclude" or just stick it next to the file and write #include "mycginclude.cginclude"
BUT
You can't get a global reference to a cginclude without slapping it into "\Unity\Editor\Data\CGIncludes" in the editor directory itself.
So I'm in a tough position because for my usecase I need a globally reference-able cginclude that exists in the project without an absolute path -- is this possible?
The terms "globally" and "absolute path" are in most cases synonymes. The CGIncludes folder of the editor also represents an absolute path. It can't be changed. Likewise you can define a fix relative path inside your project.
What's the problem with using "Assets/cgincludes/mycginclude.cginclude" if that works? If you fear the long path, place the main CG file directly inside the Assets folder:
"Assets/main.cginc"
$$anonymous$$ostly just worried about folks wanting re-organize their projects for an asset store plugin~
I know what you mean, but cg includes are purely based on file names / paths and do not represent "assets" in term of Unity's AssetDatabase. Unity doesn't provide a "default" search path or a special folder for cg includes inside projects.
Even if it would support a special folder, most special folders still need to be at the root so it's still a fix path. The only special folder names that can be anywhere are "editor" and "resources" folders. Well the $$anonymous$$aterials folder could be mentioned as well, but that's just a feature of the model importer.
If you want to provide a consistent path, place it inside a folder inside "Standard Assets" since the Standard Assets folder is always at root by definition.
Your answer
Follow this Question
Related Questions
UnityObjectToClipPos is inverted? 0 Answers
Shaders problems after moving to URP 0 Answers
Flat Shading / No Vertex Interpolation 2 Answers
Access to svPosition in fragment shader 1 Answer
Using custom keywords in cg shaders 1 Answer