- Home /
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.
Are you doing your own platform dependent configuration? Just wondering if you have an unclosed #if around somewhere...
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.
I've had the same problem, there is no real solution... It's the way $$anonymous$$ono 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.
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 ?
Nah, I haven't switched platforms for weeks now.
I would agree that this must be intended $$anonymous$$onoDevelop 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.
Your answer
Follow this Question
Related Questions
How to bind Prime31 ios storekit plugin with GUIText elements? 1 Answer
Game crashed on IOS 0 Answers
Prime31 GameCenter 2 Answers
Using and External Plugin when transferrign platforms 0 Answers
Edit asset DLL? 1 Answer