- Home /
what is #pragma
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?
#pragma strict
#pragma implicit
#pragma downcast
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.
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.
Greetz, $$anonymous$$y.
Greta, now I now... the new version of $$anonymous$$onoDevelop 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 $$anonymous$$onoDevelop.
Your answer
