Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

Question "The script is an editor script" error when script is not an editor script

Discussion in 'Editor & General Support' started by mroshaw, Jun 27, 2023.

  1. mroshaw

    mroshaw

    Joined:
    Oct 11, 2020
    Posts:
    34
    Hi! I've just recently upgraded my project from Unity 2021 to 2022 LTS. A number of my prefabs are now "broken", and analysis suggests that this is because Unity has started seeing one of my component scripts as an Editor script - even though it's not.

    If I drop that component to a Game Object, I get the error displayed: "The script is an editor script". Prefabs with this component already show an error and give me a warning when importing.

    Given the script is NOT in a folder named "Editor", and none of the parent or child folders above and below the script are named "Editor", what else does Unity evaluate to conclude that my component script is an Editor script?

    Many thanks!
     
    trefun likes this.
  2. Kurt-Dekker

    Kurt-Dekker

    Joined:
    Mar 16, 2013
    Posts:
    36,561
    Perhaps reimport all? Otherwise...


    ISSUES RELATED TO UPGRADING PROJECTS (eg, changing to a higher Unity version)

    Upgrading to a later version of Unity is a one-way process. Any project that has been updated should NEVER be reverted to an earlier version of Unity because this is expressly not supported by Unity. Doing so exposes your project to internal inconsistencies and breakage that may actually be impossible to repair.

    If you want to upgrade to a newer version of Unity, do not even consider it until you have placed your project fully under proper source control. This goes double or triple for non-LTS (Tech Stream) versions of Unity3D, which can be extremely unstable compared with LTS.

    Once you have source-controlled your project then you may attempt a Unity upgrade. Immediately after any attempted upgrade you should try to view as much of your project as possible, with a mind to looking for broken animations or materials or any other scripting errors or runtime issues.

    After an upgrade you should ALWAYS build to all targets you contemplate supporting: iOS and Android can be particularly finicky, and of course any third party libraries you use must also "play nice" with the new version of Unity. Since you didn't write the third party library, it is up to you to vet it against the new version to make sure it still works.

    If there are issues in your testing after upgrading Unity, ABANDON the upgrade, revert your project in source control and be back where you were pre-upgrade with the earlier version of Unity.

    Obviously the less you test after the upgrade the more chance you will have of an undiscovered critical issue.

    This risk of upgrading is entirely on you and must be considered whenever you contemplate a Unity version upgrade.

    Do not upgrade "just for fun" or you may become very unhappy.


    PROPERLY CONFIGURING AND USING ENTERPRISE SOURCE CONTROL

    I'm sorry you've had this issue. Please consider using proper industrial-grade enterprise-qualified source control in order to guard and protect your hard-earned work.

    Personally I use git (completely outside of Unity) because it is free and there are tons of tutorials out there to help you set it up as well as free places to host your repo (BitBucket, Github, Gitlab, etc.).

    You can also push git repositories to other drives: thumb drives, USB drives, network drives, etc., effectively putting a complete copy of the repository there.

    As far as configuring Unity to play nice with git, keep this in mind:

    https://forum.unity.com/threads/prefab-links-keep-getting-dumped-on-git-pull.646600/#post-7142306

    I usually make a separate repository for each game, but I have some repositories with a bunch of smaller test games.

    Here is how I use git in one of my games, Jetpack Kurt:

    https://forum.unity.com/threads/2-steps-backwards.965048/#post-6282497

    Using fine-grained source control as you work to refine your engineering:

    https://forum.unity.com/threads/whe...grammer-example-in-text.1048739/#post-6783740

    Share/Sharing source code between projects:

    https://forum.unity.com/threads/your-techniques-to-share-code-between-projects.575959/#post-3835837

    Setting up an appropriate .gitignore file for Unity3D:

    https://forum.unity.com/threads/removing-il2cpp_cache-from-project.1084607/#post-6997067

    Generally the ONLY folders you should ever source control are:

    Assets/
    ProjectSettings/
    Packages/

    NEVER source control Library/ or Temp/ or Logs/
    NEVER source control anything from Visual Studio (.vs, .csproj, none of that noise)

    Setting git up with Unity (includes above .gitignore concepts):

    https://thoughtbot.com/blog/how-to-git-with-unity

    It is only simple economics that you must expend as much effort into backing it up as you feel the work is worth in the first place. Digital storage is so unbelievably cheap today that you can buy gigabytes of flash drive storage for about the price of a cup of coffee. It's simply ridiculous not to back up.

    If you plan on joining the software industry, you will be required and expected to know how to use source control.

    "Use source control or you will be really sad sooner or later." - StarManta on the Unity3D forum boards
     
  3. mroshaw

    mroshaw

    Joined:
    Oct 11, 2020
    Posts:
    34
    Hello, and thanks for taking the time to respond!

    I know you're right, of course, but there's a part of me thinks that updating to the latest LTS release should be something that we're reasonably confident to do! I do have a backup that I could restore, but it feels like such a step backwards to revert and sit and hope next time it works. I totally take on board your feedback, and it is what it is of course.

    I've tried a clear down of the library and a complete rebuild. Made sure I'm on the latest LTD, 2022.3.3. Alas, the problem remains.

    It's such a stupid problem, that doesn't help either! :D All I can glean from the documentation is that Unity cares about the naming of the folders - that's just not the case here for me, so I'm baffled as to what I can actually do to understand and resolve the underlying issue.
     
  4. mroshaw

    mroshaw

    Joined:
    Oct 11, 2020
    Posts:
    34
    Apparently, this is Unity's way of telling me that I can't have a partial class with the same filename. Who'd have thunk?!
     
    Fletch2023 and David_Faulkner like this.
  5. Kurt-Dekker

    Kurt-Dekker

    Joined:
    Mar 16, 2013
    Posts:
    36,561
    What software (any software) in the world has EVER upgraded smoothly?!

    Upgrade only if you REQUIRE a feature, or if the hardware, OS, or license terms require it.