• Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
2
Question by Lex-DRL · Dec 06, 2013 at 01:37 PM · shadercg

How to specify my CGIncludes directories?

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:

  1. ./ (current directory)

  2. Unity/Editor/Data/CGIncludes/ (default directory)

How can I add some directories in this list and tell Unity to scan them in this order?

  1. ./ (current directory)

  2. Assets/MyCgLib (my folder)

  3. 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.

Comment
Add comment
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

3 Replies

· Add your reply
  • Sort: 
avatar image
2

Answer by tanoshimi · Dec 07, 2013 at 09:24 AM

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:

 #include "./relative/path/to/yourshader.cginc"
 #include "Assets/absolute/path/to/your/shader.cginc"
Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image
1

Answer by PappyA · Mar 27, 2015 at 09:30 PM

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.

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image
2

Answer by DBN · Nov 19, 2016 at 01:33 AM

I don't think it can be changed but I found all the search directories used in 5.4 via Process Monitor:

  1. The root of the project folder. (OUTSIDE the Assets folder)

  2. The same folder as the shader file.

  3. Unity\Editor\Data\CGIncludes.

(ordered from first to last)

If you want to keep them in the assets folder you could use symlinks to mirror the individual files into the search path.

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Welcome to Unity Answers

If you’re new to Unity Answers, please check our User Guide to help you navigate through our website and refer to our FAQ for more information.

Before posting, make sure to check out our Knowledge Base for commonly asked Unity questions.

Check our Moderator Guidelines if you’re a new moderator and want to work together in an effort to improve Unity Answers and support our users.

Follow this Question

Answers Answers and Comments

19 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

cginc errors 1 Answer

How to force the compilation of a shader in Unity? 5 Answers

How to determine shader center? 0 Answers

Why does this IOS / OGLES shader not match PC version? 0 Answers

Pass ShaderLab properties to Standard cginc 2 Answers


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges