Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 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 /
This question was closed Aug 13, 2017 at 01:27 PM by Bunny83 for the following reason:

The question is answered, right answer was accepted

avatar image
38
Question by bruce965 · Sep 12, 2012 at 10:33 AM · errorcrashunityeditornamespace

"UnityEditor" namespace not found...

This happens only when I try to build the project, when I run Unity no error shows. (Actually it crashes)

alt text

Any idea? Thanks.

immagine.jpg (129.9 kB)
Comment
Comments Locked · Show 1
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 komodor · Feb 21, 2014 at 10:07 AM 0
Share

platform dependent compilation

9 Replies

  • Sort: 
avatar image
113
Best Answer

Answer by gilley033 · Apr 19, 2013 at 03:16 AM

Hello, have you tried using platform dependent compilation?

I was having a similar problem with one of my scriptable objects. My scriptable object was not an editor script, but it had OnInspectorGUI code in it (used so I only had to write the inspector gui for the scriptable object once).

I fixed the issue by putting #if UNITY_EDITOR before the using UnityEditor directive and #endif after it. You will also need to surround your GUI code with these same tags.

Hope this helps!

Comment
Comments Locked · Show 10 · 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 bruce965 · Apr 19, 2013 at 04:12 AM 0
Share

I like your walkaround, if it works, than thanks for sharing.

avatar image komodor · Feb 21, 2014 at 10:06 AM 1
Share

it works perfectly, actually the "correct" answer is just stupid and does not solve all issues you might have, for example handles ... you just need them on the object

avatar image whydoidoit · Feb 21, 2014 at 10:11 AM 0
Share

Agreed, changed correct answer

avatar image mustafaguven · May 07, 2014 at 09:37 PM 0
Share

I did not understand, can someone explain it for me please? Yes since I put these commands it builds without errors but while apk running the part which I put command does not run. I just want to collect materials from a folder. Is there a way to make it? The thing that I cant understand is why do they put if it wont be usefull. How can I collect all materials in runtime, anyone knows how to do it?

avatar image JustinReinhart · Jul 23, 2016 at 07:14 AM 3
Share

I just want to clarify for people co$$anonymous$$g along trying to understand this. This question has two answers.
1. Unity intends for you--as part of your workflow--to put all scripts that modify the editor or include the UnityEditor namespace to be in a folder (or sub folder) in your project named "Editor". Folders with this name are special. On compile, Unity checks for this detail and it will overlook these scripts on compilation and not compile them into the finished build. 2. However, Gilley033's answer here is quite clever. Apparently if you want to avoid moving your scripts (for whatever reason) you can in some cases uses the platform dependent compilation code described here. I never thought about doing that. Very interesting and thanks.

Show more comments
avatar image
54

Answer by softrare · Sep 12, 2012 at 10:36 AM

You have to place this script in a directory called "Editor" in the root of your project hierarchy.

Comment
Comments Locked · Show 8 · 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 MSDs · Feb 09, 2013 at 09:37 AM 1
Share

I got same error and it solved by placed the script to Editor directory. thank u

avatar image jcaspews · Jan 25, 2015 at 05:38 PM 1
Share

This worked for me, it is a good solution to separate game/editor files

avatar image softrare · Jan 25, 2015 at 05:52 PM 1
Share

By the way. The "Editor" folder doesn't even have to be in the root (anymore?). It can be a subfolder.

avatar image awlee86 · Jun 13, 2016 at 06:01 PM 1
Share

Solved by putting every scripts that uses UnityEditor into folders called Editor. and yeah those folders don't have to be in the root folder. It seems that Unity will ignore every scripts inside Editor folder when building.( got a build error after moving one of my essential scripts into them

avatar image marvpaul · Feb 14, 2017 at 09:25 PM 1
Share

Thank you so much!

Show more comments
avatar image
15

Answer by Kryptos · Sep 12, 2012 at 11:33 AM

Built game cannot use the UnityEditor namespace. This namespace comes with the UnityEditor.dll assembly that is not shipped (and not compatible) with any build made by Unity.

Scripts that use this namespace are only meant to be executed inside Unity Editor.

Comment
Comments Locked · Show 6 · 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 bruce965 · Sep 12, 2012 at 11:37 AM 0
Share

Ok... so where should I put this script? Or what should I do to avoid build errors?

Right now I removed it, the better solution?

avatar image Kryptos · Sep 12, 2012 at 11:47 AM 2
Share

Don't use any editor capabilities inside a script that is meant to be shipped.

Try first by removing using UnityEditor;. Then cut/paste the code using this namespace into another script.

avatar image thesfid · Dec 10, 2013 at 07:24 PM 2
Share

So glad I found this thread. I thought I was clever by using UnityEditor.AnimationUtility to get animation data from characters into an array without assigning them in the inspector. So much for that idea. Thanks @$$anonymous$$ryptos!

avatar image Seth-McCumber · Dec 10, 2013 at 08:00 PM 2
Share

Put in a folder in the main assets directory called Editor

avatar image VCC_Geek · Dec 16, 2013 at 04:28 AM 0
Share

Seth got it. Works perfectly. Also kudos to $$anonymous$$ryptos for getting the first part.

Show more comments
avatar image
1

Answer by Niklasi17102000 · Jun 29, 2014 at 04:10 PM

The problem is: The namespace "UnityEditor" can only be used if you are in the Unity Editor program. I have the same Problem, too. But I need the "using UnityEditor" for one of my scripts to load files from assets.

Comment
Comments Locked · Show 4 · 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 HamFar · May 08, 2015 at 12:22 PM 0
Share

Guys, Then how do I implement a radio button (using v4.6 and OnGUI code) if I cannot have UnityEditor in my standalone? I cannot move my script, nor can I simply use #if UNITY_EDITOR tags to disable that part of code, because I want it to run in the standalone... If I put the CrossPlatformInputInitialize.cs script in my Strea$$anonymous$$gAssets meant to be built and shipped, how can I reference it?

avatar image VCC_Geek · May 08, 2015 at 01:22 PM 1
Share

@HamFar: I don't think that the radio buttons in the UnityEditor namespace were really meant for production use - only for building and testing. You'll want to go through the new GUI system documentation. I unfortunately don't have time to look, but you can start at http://docs.unity3d.com/$$anonymous$$anual/UIOverview.html which will give you a good, solid start with using the new GUI system the way it was meant to be used. Hopefully that will make life easier for you.

avatar image HamFar · May 09, 2015 at 03:59 PM 0
Share

@VCC_Geek: Thank you. I have to maintain a big software app that was developed with Unity 4.6 and OnGUI code, so upgrading to Unity 5 and using the new UI system is not an option for me. But I thought if I can figure how to reference the CrossPlatformInputInitialize.cs script that enables Editor capabilities, that will be a good hack for this dilemma! So, here is what I have written so far, and I just need to figure out what code to put ins$$anonymous$$d of the commented line:

 #if UNITY_EDITOR
 GUILayout.BeginHorizontal( displayStyle1 );
 GUILayout.Label( field.tagLine, GUILayout.Width( Screen.width/3 ) );
 selGridInt = GUILayout.SelectionGrid( selGridInt, selStrings, 3, EditorStyles.radioButton );
 GUILayout.EndHorizontal();
 inputs[i] = selStrings[ selGridInt ];
 #elif UNITY_STANDALONE
 string standalonePath = Application.strea$$anonymous$$gAssetsPath;
 string editorPath = standalonePath + Path.DirectorySeparatorChar + "Editor";
 // What goes here ??? = GetComponent<CrossPlatformInputInitialize>();
 GUILayout.BeginHorizontal( displayStyle1 );
 GUILayout.Label( field.tagLine, GUILayout.Width( Screen.width/3 ) );
 selGridInt = GUILayout.SelectionGrid( selGridInt, selStrings, 3, EditorStyles.radioButton );
 GUILayout.EndHorizontal();
 inputs[i] = selStrings[ selGridInt ];

avatar image VCC_Geek · May 09, 2015 at 10:42 PM 1
Share

@HamFar: You shouldn't need Unity 5 to have the new GUI system. I believe it was introduced in 4.6. The old system is still present in 4.6 (and 5?) for backward compatibility. That said, you might want to set up a sandbox environment with a complete copy of your codebase and Unity 5 just to see how much work it would be. $$anonymous$$y own experience has been that my projects update pretty seamlessly to newer versions. If you just tiptoe through it in the sandbox, you should be able to back out easy enough if it turns out to be too much.

avatar image
0

Answer by IPT · Oct 16, 2013 at 09:48 AM

Had the same problem, cause I have changed the location of the Orthello to be under plugins folder, when I moved it back to be under the 'Assets' folder, it fix it.

Comment
Comments Locked · 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
  • 1
  • 2
  • ›

Follow this Question

Answers Answers and Comments

31 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

Related Questions

Editor crashes after loading a project 3 Answers

Unity started rejecting my scripts? 1 Answer

What are the unityeditorinternal and the unityengineinternal namespace and why are they missing from the docs ? 1 Answer

Unity Editor freeze 1 Answer

Problem with SSL CA cert 0 Answers


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