When using preprocessors, Unity throws errors
Hi all
Si my problem is that every time I use a preprocessor:
#if UNITY_EDITOR
some code
#endif
The compiler gives me errors like the following one: "Expected `#endif' directive"
I have found in this question that it's an internal problem and that should reinstall Unity, so i did, I reinstalled the latest Unity version but the problem persisted.
Any help would be greatly appreciated.
-Jorge
They work fine for me. Always have. Try a short, known, working sample. Just in case write the Unity version and the code editor.
I think it works when i create a new project, but ill test it afterwards.
What IDE? Does #pragma statements work? It sounds like an IDE or compiler issue.
I use Xamarin and when i build it in there it works. What does #pragma statements do?
Answer by saud_ahmed020 · May 13, 2016 at 10:28 AM
@skullbeats1 Close your project then delete the Library folder from your project. Open the project and your problem resolved. :)
Your answer
![](https://koobas.hobune.stream/wayback/20220612080717im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Linux Ubuntu: Typespace 'UnityEngine' Could Not Be Found 0 Answers
Network Transport Layer API does not work with iOS to PC???? 0 Answers
Image not appearing after transferring build to Mac from PC? 0 Answers
Need components for script... 1 Answer
#if UNITY_IOS - disables everything in Visual Studio 1 Answer