So I have been trying to figure out what #pragma does. It looks like it calls some libraries but I am not sure. If it is calling libraries, what are available libraries for use and what do these libraries do?
Thanks in advance everyone!
Answer by yatayata
Sep 03, 2011 at 11:57 PM
pragma is a pre-compiler directive. ie it tells the compiler what to do or how to behave.
eg #strict - "be uptight when you compile this schizzle bro!"
They're also very helpful in optimizing your game.
how are they helpful in optimizing?
by being strict. they won't allow you to do as dirty code.
e.g. when defining a variable without #pragma you can leave out the typing and unity will figure out what the variable 's supposed to be when you use it. But the 'figuring out'-part can take a lot of resources. That's why it's considered bad habit / dirty code to not always type stuff. With #pragma you must tell of what type the variable will be and it will give you an error if you don't comply.
Greta, now I now... the new version of MonoDevelop includes #pragma strict on all new scripts. This will keep me on my toes ;-)
It's Unity 3.5 that includes #pragma strict for new scripts, not MonoDevelop.
Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.
The best place to ask and answer questions about development with Unity.
To help users navigate the site we have posted a user guide.
If you are a new user, check out our FAQ for more information.
If you are a moderator, see our Moderator Guidelines page.
We are making improvements to UA, see the list of changes.
For troubleshooting common problems with Unity 5.x Editor (including Win 10).
Answers and Comments
10 People are following this question.
What is the function of the #pragma commands
Non traditional Shader, for adding saturation
Is it o.k to save custom per-project .asset files in /Library?
Using a C file as a plugin
How to import java .class and .jar library files into Unity?