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 /
  • Help Room /
avatar image
0
Question by Rembo4Fight · Dec 31, 2017 at 12:44 PM · scripting problemunityeditorgradient

Resolve 'UnityEditor' error

Happy New Year everyone.

Help me with this question, I have the DayNightGradient package which is having an error when im building my project.

It says the type or namespace name UnityEditor could not be found.

I know that types like this must be on Editors folder But if i move that script to Editors folder, the references and many things goes wrong

So I need a resolution for this an in easiest way. Please help me out on this on, this is a long story with this problem.

If you need, the link to DayNightCycle project is here: GitHub link

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

1 Reply

· Add your reply
  • Sort: 
avatar image
0
Best Answer

Answer by Larry-Dietz · Dec 31, 2017 at 07:03 PM

Editor scripts are for use in the editor only. Nothing editor related will end up packaged in the build, so if you have actual game code dependent on an editor script, you need to refactor that code. Editor scripting is only to help you get the object set up. Not to actually do anything at run time. Even if you managed to get everything straightened out with putting it into an editor folder, it wouldn't be included in the actual build.

-Larry

Comment
Add comment · Show 7 · 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 Rembo4Fight · Dec 31, 2017 at 07:09 PM 0
Share

So you mean, that every script with the "using UnityEditor" must be only in Editors folder? Or we have some options to make it works without this folder? Can you check this asset that i have linked above, if you will try to build a project, it will type an error for 1 script. Its strange because it is the original asset without any of my changes, please if you know what to do please tell me.

avatar image Larry-Dietz Rembo4Fight · Dec 31, 2017 at 07:23 PM 0
Share

Ok, I took a look at the DayNightGradient script, and all the editor stuff in the script is wrapped in a preprocessor directive to NOT be included when built, so you should be good on that point.

I would recommend wrapping the using statement the same, and see if you can build, and that the build works as expected.

i.e.

  using UnityEditor;
     
     becomes
     
     #if UNITY_EDITOR
     using Unity_Editor;
     #endif

Give that a shot, and let me know how it works.

avatar image Rembo4Fight Larry-Dietz · Dec 31, 2017 at 08:57 PM 0
Share

Thats strange, i have changed "using UnityEditor" on DayNightCycleGradient script to what you said And so the script is not giving an error on this one But giving 3 errors on the createPlane$$anonymous$$esh script With the same UnityEditor but not on the begining, its starting with the "mesh m" I hope there is a resolve for this one..:)

Show more comments
avatar image Rembo4Fight · Dec 31, 2017 at 07:20 PM 0
Share

Or you mean I need to copy my script on editors folder?

avatar image Larry-Dietz Rembo4Fight · Dec 31, 2017 at 07:39 PM 0
Share

For this particular script, you don't need it in an editors folder. He just has some code in here that is called from another script that IS in an editor folder, and that script will only ever be called when running in the editor.

So removing that using statement from the build (which using the code I put above will do) should help you get it built. unless you have added any additional code that uses something from UnityEditor.

If that is the case, post the code you added using the UnityEditor namespace, and we can see what needs to be done.

avatar image Rembo4Fight Larry-Dietz · Jan 03, 2018 at 05:51 AM 0
Share

Thank you for your help I checked #if UnityEditor thing and it helped Im just added this at the start and the end of the script And it works You can look at this in here! :) thank you again

alt text

screen-shot-2018-01-03-at-085036.png (410.8 kB)
screen-shot-2018-01-03-at-085039.png (363.8 kB)

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

174 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 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 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

Playerprefs are not deleting when an apk is uninstalled? 0 Answers

Why IF doesn't work with Instantiate? 1 Answer

Mobile attack button isn't doing damage to enemy 0 Answers

Why am i getting errors? 1 Answer

How can I replace objects in the initial position? 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