Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 Jun 22
sparklines
Close Help
  • 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
0
Question by Johanna_H · Jul 06, 2017 at 01:46 PM · platforms

Why is platform dependent code not working

 #if !UNITY_EDITOR
 using Microsoft.AspNet.SignalR.Client;
 #endif

When I run my project in the editor it works fine. But when I want to build my project I am being told:

Error building Player because scripts had compiler errors.

But I am not shown where. When I comment the code above out everything works fine and I can build my project whithout any trouble. Is there any way to solve this? Right now I have to comment code out every time I have a new version just to have it back to normal in the build version. Thanks for your help!

Comment
Add comment
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

2 Replies

· Add your reply
  • Sort: 
avatar image
0

Answer by Bunny83 · Jul 06, 2017 at 02:27 PM

Since this usins statement is only active when you're not in the editor (which mean it is only used when you build your game) and you don't seem to require that namespace anywhere you can completely remove the line.

If for some reason you do need it (maybe for some framework that you don't use yet) you should check that you have the actual assembly as well as all dependencies in your project. However if you have no idea for what you need it and the project build fine without it i doubt you actually require it. Inside which file / script is that code fragment located?

Comment
Add comment · Show 5 · Share
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 Jwizard93 · Jul 06, 2017 at 04:00 PM 1
Share

Im curious, did you add your reference to that DLL your are "using"?

avatar image Bunny83 Jwizard93 · Jul 06, 2017 at 04:12 PM 1
Share

You can't manually add a reference to a DLL in Unity. Well you can but Unity will overwrite it anyways. You have to copy your DLLs into your project (plugins folder). Unity will automatically add the references for all assemblies in your project.

avatar image Glurth Bunny83 · Jul 06, 2017 at 08:45 PM 0
Share

I think these two comments are the actual answer to the OP. The DLL referenced by the "using" statement has NOT been put in this folder, and so the automatically-generated reference fails, when attempting a build that actually uses it (!EDITOR_UNITY).

avatar image Johanna_H Jwizard93 · Jul 10, 2017 at 09:12 AM 0
Share

I did add a Reference with Visual Studio NUGet in the build version of the project

avatar image Johanna_H · Jul 10, 2017 at 07:29 AM 0
Share

Thanks a lot for your reply! So I do use the code behind the using and where I do I have to comment it out too. I just wanted to make my question simpler. I have that code in a normal script which I added to a gameobject. I the build version I added the code content of SignalR.Client via NuGet.

avatar image
0

Answer by LilGames · Jul 06, 2017 at 02:43 PM

Do builds complete? You're going to have to debug from a build rather than in the editor. Make sure you build a development build.

Comment
Add comment · Show 1 · Share
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 Johanna_H · Jul 10, 2017 at 07:31 AM 0
Share

I do that but to create a build I always have to comment out some parts of the code which I don´t want since that is quite an effort.

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.

Follow this Question

Answers Answers and Comments

71 People are following this question.

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

Related Questions

How to compensate for moving platforms that move side to side 2 Answers

How can I create an animation of platforms 1 Answer

toggle rigidbody constraints? 1 Answer

Sync assets that are built in different platforms 0 Answers

Building Question 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