Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Compile Errors in Unity Editor #9

Closed
madclouds opened this issue Feb 24, 2015 · 5 comments
Closed

Compile Errors in Unity Editor #9

madclouds opened this issue Feb 24, 2015 · 5 comments

Comments

@madclouds
Copy link

Hey Banbury!

I can't believe how difficult it is to get PSD data into Unity. You'd think they'd build it in natively. I don't want to re-position/layer all the work my designer has already done!

I'm very excited for this plugin! Unfortunately, I can't get it to compile correctly in the Unity Editor. Unity keeps displaying console errors:

Assets/PhotoShopFileType/PsdFile/Layers/Channel.cs(273,25): error CS0227: Unsafe code requires the 'unsafe' command line option to be specified
Assets/PhotoShopFileType/PsdFile/Layers/Layer.cs(206,11): error CS0227: Unsafe code requires the 'unsafe' command line option to be specified
Assets/PhotoShopFileType/PsdFile/PsdBinaryReader.cs(80,7): error CS0227: Unsafe code requires the 'unsafe' command line option to be specified
etc...

I tried to follow your readme.md but I didn't quite understand this paragraph:

To compile the Unity PSD Importer in the Unity3D Editor you must have the files gmcs.rsp and smcs.rsp with "-unsafe" in the first line of the files in the root directory of your project. Otherwise you can compile the code as a DLL and it will also work in the editor.

When I moved gmcs.rsp and smcss.rsp to my projects root directory, it had no effect. Should I be adding the unsafe comment to every .cs file affected?

I should mention I'm on a MacBook Pro running OS X 10.10.2 and Unity 4.6.2f1

@Banbury
Copy link
Owner

Banbury commented Feb 24, 2015

Here's some documentation on how to modify the compile options in Unity:
http://docs.unity3d.com/Manual/PlatformDependentCompilation.html

gmcs.rsp and smcs.rsp seem to be used to add additional compiler switches (in this case '-unsafe') to the calls of the C# compiler.
Personally I prefer to compile the code as a DLL in a separate solution. Then I copy the DLL to the game folder.

@madclouds
Copy link
Author

Thanks for responding so quickly Banbury!

Compiling the code as a DLL and copying it to the game folder does seem like an easier solution. I thought the DLL extension was windows only? Any idea if this will work on a mac too?

May I ask what technique you use to compile the DLL?

@madclouds
Copy link
Author

A quick search turned up these resources:

http://docs.unity3d.com/Manual/UsingDLL.html

http://forum.unity3d.com/threads/creatng-windows-usable-dll-in-osx.99348/

I'll see if there's a way to build it using MonoDevelop.

@Banbury
Copy link
Owner

Banbury commented Feb 24, 2015

DLLs in DotNet are different. They are executed on a Virtual Machine. For Unity this is called Mono. And as long as you don't use any features, that Mono doesn't support, you can use DLLs compiled with Micorsoft's .NET compiler. For PSDImporter you have to allow unsafe code. I don't know, how this is done in MonoDevelop, but in Visual Studio this is a switch in the project properties.
I'm closing this issue now, because everything else can be found via Google.

@Banbury Banbury closed this as completed Feb 24, 2015
@madclouds
Copy link
Author

Thanks again for the help on this topic Banbury - and for authoring such a great tool!

For anyone else who may find this thread, I was able to get the Editor plugin working on my mac simply by going to Edit > Project Settings > Player and under the "Other Settings" adding 'unsafe' to the Scripting Define Symbols section:

unsafe

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants