• 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 vexe · Dec 27, 2013 at 02:00 AM · compilercompilation

Custom compilation? (Compile only changed files)

When I was in ArchLinux, writing C++ code, I used to have them MakeFile files to specify exactly how I want compilation to be. Something like this:

 program_NAME := binary
 program_C_SRCS := $(wildcard *.c)
 program_CXX_SRCS := $(wildcard *.cpp)
 program_C_OBJS := ${program_C_SRCS:.c=.o}
 program_CXX_OBJS := ${program_CXX_SRCS:.cpp=.o}
 program_OBJS := $(program_C_OBJS) $(program_CXX_OBJS)
 program_INCLUDE_DIRS := ./include
 program_LIBRARY_DIRS :=
 program_LIBRARIES :=
 program_HEADERS := $(wildcard *.h)
 
 CPPFLAGS += $(foreach includedir,$(program_INCLUDE_DIRS),-I$(includedir))
 LDFLAGS += $(foreach librarydir,$(program_LIBRARY_DIRS),-L$(librarydir))
 LDFLAGS += $(foreach library,$(program_LIBRARIES),-l$(library))
 CXXFLAGS += -g
 
 .PHONY: all clean distclean
 
 all: $(program_NAME)
 
 $(program_OBJS): $(program_HEADERS)
 
 $(program_NAME): $(program_OBJS)
     $(LINK.cc) $(program_OBJS) -o $(program_NAME)
 
 clean:
     # @- $(RM) $(program_NAME)
     @- $(RM) $(program_OBJS)
 
 distclean: clean


Thus, when I build, only the files that did change gets recompiled.

Can this be achieved in Unity? in someway? I really don't like the fact that my whole project gets recompiled just cause I added a Debug.Log - And yes, I read this, and it doesn't say much.

Thanks.

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

1 Reply

· Add your reply
  • Sort: 
avatar image
2
Best Answer

Answer by Benproductions1 · Dec 27, 2013 at 02:34 AM

Hello,

In Unity there are a few different "levels" of scripts. As you probably know some files in special folders get compiled before others, such as anything in an Editor folder, or anything in the Standard Assets. These levels can be slit up like so:

  1. Everything in an Editor folder in Standard Assets gets compiled. Boo and UJS get compiled into one assembly, while C# gets compiled into another.

  2. Everything in the Standard Assets folder, that isn't in Editor gets compiled. The language split up is the same throughout the entire proccess.

  3. Everything outside of the Standard Assets in an Editor folder gets compiled.

  4. Everything outside of both the Standard Assets and any Editor folder gets compiled.

When all the scripts in one of these levels get compiled, they are all put together into one big source. So when you write different scripts in the same level, you're basically writing one big file. I'm pretty sure that even in C++ you can't compile pieces of a file individually ;)

In the end you end up with 8 assemblies altogether. I'm pretty sure that Unity doesn't recompile all of them if only one has been changed, so therefore the most optimisation that can be done is already done.

The only way around this is to compile your own assemblies into dynamically linked libraries and put those into the Pligins folder. I found a editor script on the wiki that does this with C# files here. It probably won't work with any scripts that are not self-contained, but you never know ;)

Hope this helps,
Benproductions1

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

Error "side-by-side configure is incorrect" when compiling the game 2 Answers

AOT compilation problem - ExecutionEngineException - AOT not compiling as expected. 1 Answer

Compiler error - how to fix it? 0 Answers

Is it possible to compile and run C# code on-the-fly on mobile? 1 Answer

When building a script, says semicolon is missing. 1 Answer


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