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 /
avatar image
0
Question by Swistakk · Jun 10, 2014 at 11:29 AM · editorbuildnamespace

"UnityEditor" could not be found

Hi. I'm really new to Unity and I'm currently creating a game where I need to do some painting dots, lines etc. I used "Handles" to do those paintings. Another thing I need are message boxes which are provided by UnityEditor namespace as EditorUtility.DisplayDialog .

So far I ran my game only in Editor and everything worked, but I wanted to build it and I got error "The type or namespace name `UnityEditor' could not be found. Are you missing a using directive or an assembly reference?". I did some googling and found this subject http://answers.unity3d.com/questions/316805/unityeditor-namespace-not-found.html but I'm not sure that I understand what people are saying there. Some people say that functionalities provided by UnityEditor can be used in Editor only, some people say that script using those should be moved to "Editor" folder. I hope that I can use those functionalities in a build (for Windows), because providing functionalities which work in UnityEditor only seems really weird to me... So I tried moving script GameManager.cs to Editor folder and when I did it I received following warning "The class named 'GameManager' is not derived from MonoBehaviour or ScriptableObject!" and indeed, the whole game is not working, although I got line "public class GameManager : MonoBehaviour {". Maybe I should create a new file and put there only a part of GameManager.cs ?

Is there a way I can use Handles and EditorUtility.DisplayDialog in Windows Build? What should I do?

Comment
Add comment · 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 vexe · Jun 13, 2014 at 10:31 PM 0
Share

EditorUtility.DisplayDialog is an editor thing only. It's not a runtime GUI thing. You should make one yourself. When you put something in the Editor folder you're saying: This won't be included in the build, this is just when working inside the Editor.

2 Replies

· Add your reply
  • Sort: 
avatar image
2

Answer by tanoshimi · Jun 10, 2014 at 12:04 PM

The people that said you can't use functionality of the UnityEditor namespace in a build are correct. If you want that functionality in a game you'll have to write it yourself or find an asset that does it.

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

Answer by Nerevar · Jun 10, 2014 at 12:13 PM

Hello,

You can not build a MonoBehaviour class using the UnityEditor namespace elements. You have to create a specific script derived from editor class and put it in the editor folder. Then use on this script the functionnalities you want that needs the UnityEditor namespace.

A little example:

Your general Class:

 using UnityEngine;
 using System.Collections;
 
 public class dialogue : MonoBehaviour {
 
     public string message = "Hello World";
     
 }

Your Editor script:

 using UnityEngine;
 using System.Collections;
 using UnityEditor;
 
 [CustomEditor(typeof(dialogue))]
 public class dialogueEditor : Editor{
 
     bool init;
 
     public override void OnInspectorGUI(){
         dialogue myScript = (dialogue)target;
         if(!init){
             EditorUtility.DisplayDialog("exemple", myScript.message,"Yes","No");
             init = true;
         }
     }
 }
Comment
Add comment · Show 3 · 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 Swistakk · Jun 10, 2014 at 02:45 PM 0
Share

Thank for your response, it definitely gives me some hope :)! But I can't make it working properly yet. After painting in function OnInspectorGUI() I got something like this picture in attachment which is probably not what I want :D. New message box pops out every time I'm switching focus on a list of objects on the left to "_G$$anonymous$$" (which is an empty object with script Game$$anonymous$$anager.cs assigned) and these lines and dots are painted ... on an inspector in fact :D. Of course I want these lines to be painted on a scene when I run my game.

[1]: /storage/temp/27540-unityzonk.png

unityzonk.png (176.8 kB)
avatar image Bunny83 · Jun 10, 2014 at 03:19 PM 0
Share

@Nerevar: I think you should read the question more carefully. It's clear that Swistakk wants to use that things at runtime and not just in the editor.

@Swistakk: No, unfortunately there's no hopw ;) The UnityEditor namespace and it's related assembly just wraps functionality that belongs to the editor application itself. This assembly can't be used in a build. That's why it's called UnityEditor ;)

If you want to draw lines / dots at runtime, use the GL class.

For message / dialog boxes you might be able to use the ones that comes with .NET. It depends on what kind of dialog you need. Usually you would create such things with ingame graphics / GUI.

Here's an old example i did in the past to explain how FixedUpdate works ;) The whole thing is done with 1 script and uses the GL class to draw most things. The "windows" are normal GUI windows.

avatar image Nerevar · Jun 10, 2014 at 05:20 PM 0
Share

@Bunny83 Yes but to me it was not quite clear what he wanted to achieve as he looked not familiar with the editor.

And Yes if He wants special customed GUI elements at runtime he may have to code it himself.

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

24 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

Related Questions

Distribute terrain in zones 3 Answers

Global Illumination is radically different between editor and built apps 0 Answers

Is there an event triggered before editor starts rebuilding scripts? 1 Answer

Build Standalone (.exe) with google cardboard VR. 1 Answer

Build and Editor collisions behaving different? 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