• 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
Question by Argembarger · Sep 14, 2014 at 03:46 AM · pluginmonodevelopprime31cs0103

MonoDevelop #if causes issue with code completion context

So I'm using the Prime31 Game Center plugin for an iOS project. And every once in a while, one of the scripts in the plugin will just go haywire, and anything referencing it will get a CS0103 "name does not exist in current context" error from that moment until I eventually deal with it.

This error only appears in MonoDevelop, and Unity is perfectly happy to build/run/whatever.

I've got all of the proper 'using' statements and nothing is improperly inheriting MonoBehaviour, or anything like that. It's not a "real" issue, it's just annoying.

What I notice is, if I go to one of the scripts which has suddenly gone missing in the solution (like GameCenterTurnBasedBinding, in this case), everything beyond the preprocessor #if UNITY_IPHONE statement is greyed out, as if it has been commented out. If I comment out the #if and the #endif, everything comes back and I'm able to use code completion as usual.

But removing platform-specific compilation directives seems like a sub-par solution.

I've tried restarting my computer to see if restarting Unity solves the issue, but it doesn't. I've heard others suggest deleting the solution files, but I just am curious why this is happening in the first place. It looks like Assembly-CSharp-firstpass is the location of the Game Center plugin, so is that the one I should try to delete?

It's just confusing, because MonoDevelop is perfectly happy and content, until it randomly decides to take issue with #ifs for no discernible reason and in a way which seems to have no consequences whatsoever except to make the act of coding somewhat more annoying.

I've had this happen on both Mac OS X and Windows 7, and I'm using Unity Pro.

Comment

People who like this

0 Show 7
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 Kiwasi · Sep 14, 2014 at 06:18 AM 0
Share

Are you doing your own platform dependent configuration? Just wondering if you have an unclosed #if around somewhere...

avatar image Argembarger · Sep 15, 2014 at 03:03 PM 0
Share

Nah, it's all in the prime31 plugin, which appears to have all of its pertinent #ifs #endif'd properly.

Although, I will say, I have done my own platform-dependent stuff in the past, and the same issue tends to crop up after a while in those scripts as well.

avatar image jokim · Sep 15, 2014 at 03:49 PM 0
Share

I've had the same problem, there is no real solution... It's the way Mono develop actually deals with #if conditions, It just won't "compile" anything that isn't on your current platform. And Yes it's annoying.

For clarity sake, here's an example :

Build settings set to iOS platform.

 #if UNITY_ANDROID
 public class AndroidClass
 {
     public AndroidClass()
     {
     }
 }
 #endif
 

Now, anywhere else in the code, let's say The update function on a script attached to the camera :

 void Update()
 {
     if (!created)
     {
 #if UNITY_ANDROID
         //Here, The class won't show up on auto-completion. It gets complicated to code stuff on that platform unless you're actually on it.
         AndroidClass myClass = new AndroidClass();
 #endif
         created = true;
     }
 }


If i was to have functions in AndroidClass, doing myClass. (myClass, followed with a dot) won't bring those functions up.

avatar image jokim · Sep 15, 2014 at 03:55 PM 0
Share

I actually forgot where i was going while typing this out, And after re-reading your post, I might have misunderstood your problem.

I had a question for you, Did you switch platform at some point ?

avatar image Argembarger · Sep 15, 2014 at 11:29 PM 0
Share

Nah, I haven't switched platforms for weeks now.

I would agree that this must be intended MonoDevelop behavior, except that it was perfectly happy to autocomplete functions and classes surrounded by platform-dependent directives, until it randomly decided that it wasn't anymore.

I guess it's not fair to call it "random", but if it was my fault, I have no idea what I did. I didn't even have the files open when they started having this problem.

Show more comments

0 Replies

· Add your reply
  • Sort: 

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

6 People are following this question.

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

Related Questions

Prime31 Social Breaking Unity Ads 0 Answers

weird false cs0103 error in monodevelop 3 Answers

Import C# project into my Unity solution 1 Answer

Make MonoDevelop respect smcs.rsp 0 Answers

How does a iOS prime31 Storekit plugin work? 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