2D Toolkit Forum
2D Toolkit => Support => Topic started by: Zec on July 06, 2012, 08:11:29 pm
-
I'm having issues compiling my projects that use 2D Toolkit in Visual Studio 2010 Express (probably the other versions as well though). I've done some investigation and I've found out in atleast the first case it's an error with the #if UNITY_EDITOR statement. I'll give an example of where my project fails compiling in Visual Studio.
sprite.EditMode__CreateCollider();
The method displayed in the code above does not exist as UNITY_EDITOR isn't defined, although the code that uses the method exist anyways. For some reason it works fine to compile in MonoDevelop though. I suppose I might be able to temporarily fix the issue by manually defining UNITY_EDITOR in my project, but Unity would just overwrite it anytime I do any changes.
I believe this issue might be part of your most recent updates, as basically all the files that contain such errors seem to be new features. You can find all 24 errors below, I even formatted them a bit and removed unnessecary info.
Error 1: 'tk2dAnimatedSprite' does not contain a definition for 'EditMode__CreateCollider' and no extension method 'EditMode__CreateCollider' accepting a first argument of type 'tk2dAnimatedSprite' could be found (are you missing a using directive or an assembly reference?) @ tk2dAnimatedSpriteEditor.cs line 134
Error 2: 'tk2dTileMap' does not contain a definition for 'DeleteSprites' and no extension method 'DeleteSprites' accepting a first argument of type 'tk2dTileMap' could be found (are you missing a using directive or an assembly reference?) @ tk2dTileMapSceneGUI.cs line 239
Error 3: 'tk2dTileMap' does not contain a definition for 'HasColorChannel' and no extension method 'HasColorChannel' accepting a first argument of type 'tk2dTileMap' could be found (are you missing a using directive or an assembly reference?) @ tk2dTileMapSceneGUI.cs line 281
Error 4: 'tk2dTileMap' does not contain a definition for 'BeginEditMode' and no extension method 'BeginEditMode' accepting a first argument of type 'tk2dTileMap' could be found (are you missing a using directive or an assembly reference?) @ tk2dTileMapEditor.cs line 557
Error 5: 'tk2dTileMap' does not contain a definition for 'AreSpritesInitialized' and no extension method 'AreSpritesInitialized' accepting a first argument of type 'tk2dTileMap' could be found (are you missing a using directive or an assembly reference?) @ tk2dTileMapEditor.cs line 639
Error 6: 'tk2dTileMap' does not contain a definition for 'BeginEditMode' and no extension method 'BeginEditMode' accepting a first argument of type 'tk2dTileMap' could be found (are you missing a using directive or an assembly reference?) @ tk2dTileMapEditor.cs line 710
Error 7: 'tk2dTileMap' does not contain a definition for 'HasColorChannel' and no extension method 'HasColorChannel' accepting a first argument of type 'tk2dTileMap' could be found (are you missing a using directive or an assembly reference?) @ tk2dTileMapEditor.cs line 793
Error 8: 'tk2dTileMap' does not contain a definition for 'CreateColorChannel' and no extension method 'CreateColorChannel' accepting a first argument of type 'tk2dTileMap' could be found (are you missing a using directive or an assembly reference?) @ tk2dTileMapEditor.cs line 798
Error 9: 'tk2dTileMap' does not contain a definition for 'BeginEditMode' and no extension method 'BeginEditMode' accepting a first argument of type 'tk2dTileMap' could be found (are you missing a using directive or an assembly reference?) @ tk2dTileMapEditor.cs line 799
Error 10: 'tk2dTileMap' does not contain a definition for 'HasColorChannel' and no extension method 'HasColorChannel' accepting a first argument of type 'tk2dTileMap' could be found (are you missing a using directive or an assembly reference?) @ tk2dTileMapEditor.cs line 820
Error 11: 'tk2dTileMap' does not contain a definition for 'DeleteColorChannel' and no extension method 'DeleteColorChannel' accepting a first argument of type 'tk2dTileMap' could be found (are you missing a using directive or an assembly reference?) @ tk2dTileMapEditor.cs line 827
Error 12: 'tk2dTileMap' does not contain a definition for 'BeginEditMode' and no extension method 'BeginEditMode' accepting a first argument of type 'tk2dTileMap' could be found (are you missing a using directive or an assembly reference?) @ tk2dTileMapEditor.cs line 828
Error 13: 'tk2dTileMap' does not contain a definition for 'BeginEditMode' and no extension method 'BeginEditMode' accepting a first argument of type 'tk2dTileMap' could be found (are you missing a using directive or an assembly reference?) @ tk2dTileMapEditor.cs line 940
Error 14: 'tk2dTileMap' does not contain a definition for 'BeginEditMode' and no extension method 'BeginEditMode' accepting a first argument of type 'tk2dTileMap' could be found (are you missing a using directive or an assembly reference?) @ tk2dTileMapEditor.cs line 951
Error 15: 'tk2dTileMap' does not contain a definition for 'EndEditMode' and no extension method 'EndEditMode' accepting a first argument of type 'tk2dTileMap' could be found (are you missing a using directive or an assembly reference?) @ tk2dTileMapEditor.cs line 965
Error 16: 'tk2dTileMap' does not contain a definition for 'EndEditMode' and no extension method 'EndEditMode' accepting a first argument of type 'tk2dTileMap' could be found (are you missing a using directive or an assembly reference?) @ tk2dTileMapEditor.cs line 975
Error 17: 'tk2dTileMap' does not contain a definition for 'AreSpritesInitialized' and no extension method 'AreSpritesInitialized' accepting a first argument of type 'tk2dTileMap' could be found (are you missing a using directive or an assembly reference?) @ tk2dTileMapEditor.cs line 995
Error 18: 'tk2dStaticSpriteBatcher' does not contain a definition for 'scale' and no extension method 'scale' accepting a first argument of type 'tk2dStaticSpriteBatcher' could be found (are you missing a using directive or an assembly reference?) @ tk2dStaticSpriteBatcherEditor.cs line 92
Error 19: 'tk2dSprite' does not contain a definition for 'EditMode__CreateCollider' and no extension method 'EditMode__CreateCollider' accepting a first argument of type 'tk2dSprite' could be found (are you missing a using directive or an assembly reference?) @ tk2dStaticSpriteBatcherEditor.cs line 126
Error 20: 'tk2dStaticSpriteBatcher' does not contain a definition for 'scale' and no extension method 'scale' accepting a first argument of type 'tk2dStaticSpriteBatcher' could be found (are you missing a using directive or an assembly reference?) @ tk2dStaticSpriteBatcherEditor.cs line 148
Error 21: 'tk2dStaticSpriteBatcher' does not contain a definition for 'scale' and no extension method 'scale' accepting a first argument of type 'tk2dStaticSpriteBatcher' could be found (are you missing a using directive or an assembly reference?) @ tk2dStaticSpriteBatcherEditor.cs line 158
Error 22: 'tk2dStaticSpriteBatcher' does not contain a definition for 'scale' and no extension method 'scale' accepting a first argument of type 'tk2dStaticSpriteBatcher' could be found (are you missing a using directive or an assembly reference?) @ tk2dStaticSpriteBatcherEditor.cs line 158
Error 23: 'tk2dBaseSprite' does not contain a definition for 'EditMode__CreateCollider' and no extension method 'EditMode__CreateCollider' accepting a first argument of type 'tk2dBaseSprite' could be found (are you missing a using directive or an assembly reference?) @ tk2dSpriteEditor.cs line 83
Error 24: 'tk2dBaseSprite' does not contain a definition for 'EditMode__CreateCollider' and no extension method 'EditMode__CreateCollider' accepting a first argument of type 'tk2dBaseSprite' could be found (are you missing a using directive or an assembly reference?) @ tk2dSpriteEditor.cs line 92
-
I don't get any issues with VS2010 Pro (don't have Express installed). I do have to open up the sln manually in VS though, double clicking simply opens up MonoDevelop even though I've set up open in VS 2010.
To debug this, check the .csproj files generated by Unity, and "Project / PropertyGroup / DefineConstants" in the XML tree. Assembly-CSharp.csproj and Assembly-CSharp-Editor.csproj (and Assembly-CSharp-firstpass, if you've done the SetupForJS thing) contain the "UNITY_EDITOR" define set.
The issue here is that the define which should be set isn't present in yours. The full line in mine is:
<DefineConstants>DEBUG;TRACE;UNITY_3_5_3;UNITY_3_5;UNITY_EDITOR;ENABLE_PROFILER;UNITY_STANDALONE_WIN;ENABLE_GENERICS;ENABLE_DUCK_TYPING;ENABLE_TERRAIN;ENABLE_MOVIES;ENABLE_WEBCAM;ENABLE_MICROPHONE;ENABLE_NETWORK;ENABLE_CLOTH;ENABLE_WWW;ENABLE_SUBSTANCE</DefineConstants>
What is set in your .csproj?
-
I actually noticed I have the same issues with other dependancies. Also, you're right. I guess that's my problem then. I have nothing defined, and even though I recreate/resync my projects using Unity, the defines does not work.
Anyways, thanks for giving me the list of defines I should use, I'll just have to add them manually.
Edit:
I actually also have that irritating issue where MonoDevelop opens instead of Visual Studio. What's even more irritating is that the most recent update of Unity is supposed to support both VS2010 and 2008, but even though I select VS2008 it generates solution files for 2010. I sure hope they can sort it out soon, cause I can't stand this Express Edition -_-
-
Might be worth trying monodevelop as the default editor, and then use VS to load the .sln. Might work better, since you say you have no problems loading with MonoDevelop - the defines will most likely be set up correctly there.
-
Found the solution to the issue. The Unity.sln file that was generated was using the "Assembly-CSharp.csproj" and "Assembly-CSharp-Editor.csproj" projects. I suspect they were made for MonoDevelop. When I manually made a VS2008 Solution I accidently used the "Assembly-CSharp-vs.csproj" and "Assembly-CSharp-Editor-vs.csproj" projects, which turned out to work just fine, no compilation errors and all defines were there. I then tried switching to the other two projects (the "non-vs named projects"), and once again the defined symbols were gone. Finally found the reason :D
No compilation errors anymore. Problem solved!
Thanks for the assistance.
-
Found the solution to the issue. The Unity.sln file that was generated was using the "Assembly-CSharp.csproj" and "Assembly-CSharp-Editor.csproj" projects. I suspect they were made for MonoDevelop. When I manually made a VS2008 Solution I accidently used the "Assembly-CSharp-vs.csproj" and "Assembly-CSharp-Editor-vs.csproj" projects, which turned out to work just fine, no compilation errors and all defines were there. I then tried switching to the other two projects (the "non-vs named projects"), and once again the defined symbols were gone. Finally found the reason :D
No compilation errors anymore. Problem solved!
Thanks for the assistance.
Glad its sorted.
Strangely, both the vs and non-vs versions worked in VS2012 for me. Doesn't really matter now that you have something that works, but just a fyi.