Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 14 Next capture
2021 2022 2023
2 captures
12 Jun 22 - 14 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 BlueMango10 · May 07, 2020 at 01:58 PM · visual studiocustom editorunityvs

Editor scripts can't access other scripts in VS

Inside editor scripts, VisualStudio's intellisense cannot see the rest of my project.

alt text As you can see, VisualStudio can't seem to find my PathMover class. Inside the Unity editor, the script works fine, so it seems like a problem with intellisense.

This seems to be an issue with my project since any new projects i create doesn't have this problem.

EDIT:
After some more experimentation it seems to be a problem with my unity version (2019.3.12f1). The 'new projects' i created to try and reproduce the problem were apparently created in an older version. After creating a new project in the same version, i encountered the same problem, so my conclusion is that it's a problem with unity rather than my project.

vsproblem.png (3.0 kB)
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 celinedrules · May 07, 2020 at 11:56 PM 0
Share

I have the exact same issue. It seemed to happen after I updated to the latest version of Unity. I tired everything possible. I even uninstalled and reinstalled Visual Studio and Unity no no avail.

6 Replies

· Add your reply
  • Sort: 
avatar image
4

Answer by Rachan · Aug 26, 2021 at 12:54 PM

same as me too on Unity 2019.4.13f1

You have to go to Edit > Preference > Eternal tools and click Regenerate Project file

this is should be happen so often, so Unity made this action to a Button everything fixed!!

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 breylinlee · Mar 26 at 07:08 PM 0
Share

This works fine. By the way, if you can't see "Renerate Project file" in the "Eternal tools" tab, just click the "External Script Editor" list, choose "Visual Studio Community 20xx", and then you will see the "Generate .csproj files for" option.

avatar image
1

Answer by AbandonedCrypt · Feb 12, 2021 at 12:39 PM

Everyone is giving solutions but I don't see anyone mentioning this (which I assume to be the actual solution):

Editor scripts should always be in a Folder (or subfolder of) named "Editor". Editor scripts (inside a folder "Editor") can not see scripts which are not in an "Editor" Folder. Vice versa, non-editor scripts can not access editor-scripts. You can Have "Editor"-Folders wherever you want in your folder structure.

This is simply due to the fact that unity excludes the editor folders from builds, since editor-code is supposed to be used at design-/editor-time and this way unity makes sure that there's no referencing of scripts that won't be present in the final build. @BlueMango10

Comment
Add comment · Show 2 · 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 Bunny83 · Apr 15, 2021 at 11:23 AM 0
Share

Editor scripts (inside a folder "Editor") can not see scripts which are not in an "Editor" Folder.

No, that's actually wrong. What would be the point of editor scripts, if they can't access any of the project scripts / data they are supposed to work on?


There's a clear hierarchy of the 4 seperate projects / assemblies that are created by Unity. It's documented over here. There are 4 compilation "phases". Each phase will result in a seperate assembly. Though those assemblies depend on each other in a strict hierarchical way. We have

 "Assembly-CSharp-firstpass"
     - (depends on nothing)
 "Assembly-CSharp-Editor-firstpass"
     - Depends on "Assembly-CSharp-firstpass"
 "Assembly-CSharp"
     - Depends on "Assembly-CSharp-firstpass"
 "Assembly-CSharp-Editor"
     - Depends on "Assembly-CSharp-firstpass"
     - Depends on "Assembly-CSharp"
     - Depends on "Assembly-CSharp-Editor-firstpass"

Scripts in one of those assemblies can access anything in a depending assembly, but not the other way round.


So "Assembly-CSharp-firstpass" contains runtime scripts and is compiled first. Those are scripts that are inside the plugins folder or Standard Assets folder. Those can not access anything outside that compilation group.


The "Assembly-CSharp-Editor-firstpass" contains all editor scripts which are in an editor subfolder in one of the special folders from the first group (i.e. inside plugins/editor or even deeper nested "editor" folders). Those editor scripts only have access to runtime scripts from the first compilation group. So they have access to everything defined in "Assembly-CSharp-firstpass".


The "Assembly-CSharp" is the "normal" assembly which contains all your runtime scripts which do not belong in the first group. So all scripts that are not in any of the special folders of the first two compilation groups. Though scripts in this group can access everything from the "Assembly-CSharp-firstpass" group, but not the other way round.


Finally there's tne "normal" editor assembly "Assembly-CSharp-Editor" which is compiled last. It has access to everything that was compiled before.


When you open the solution that Unity generates you should have seperate projects for each group that you have actually in use. Just check the "references" and you will find the DLL of the dependencies I mentioned (if they exist). Note that VS can only "see" the classes in those other assemblies when they have been recompiled in Unity. Make sure you have the Unity Tools installed in Visual Studio. It takes care synchronisation between VS and Unity.

avatar image Bunny83 Bunny83 · Apr 15, 2021 at 11:34 AM 0
Share

ps: It should be clear that Assembly-CSharp-firstpass and Assembly-CSharp are actually shipped with your game while


Assembly-CSharp-Editor-firstpass and Assembly-CSharp-Editor are not included in your game.

avatar image
0

Answer by fblast1 · May 07, 2020 at 02:29 PM

Try this,

First backup your project

Delete .csproj files , .sln file and library folder

Run the project and open any script , see if it fixes the issue


Regards

Comment
Add comment · 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 BlueMango10 · May 07, 2020 at 03:22 PM 0
Share

Thanks for the answer! Unfortunately, this didn't work. After some more experimentation it seems to be a problem with my unity version (2019.3.12f1). The 'new projects' i created to try and reproduce the problem were apparently created in an older version. After creating a new project in the same version, i encountered the same problem, so my conclusion is that it's a problem with unity rather than my project.

avatar image fblast1 · May 07, 2020 at 03:34 PM 0
Share

it is possible to be an issue since you can reproduce it

try updating visual studio itself to latest version since it might be compatibility issue


Regards

avatar image BlueMango10 fblast1 · May 07, 2020 at 06:32 PM 0
Share

I've just updated visual studio as you suggested, but unfortunately it didn't make any difference.

avatar image fblast1 fblast1 · May 07, 2020 at 07:04 PM 0
Share

well you can try two more things :

1-to change api compatibility or 2-check the external script editor inside external tools at preference

restart unity in both


Regards

avatar image
0

Answer by BenWiller1989 · Jan 31, 2021 at 09:13 PM

I had the same issue. For me the only solution was the following :


The solution :


1. Go to your Projectmap-Explorer (I am German and don't know how it's called in English).


2. Right click on References and then left click on "add references". The reference-manager-window should open.alt text


3. On Assembly and COM search the "Accessibility"-reference, and on Project the "Assembly-CSharp-Editor"-Reference toggle (should be the first toggle on all three toggle-Lists) and set them to true.alt text


Then click OK and your script should be able to reference all of your classes now, no matter if in the editor or resources folder. You might have to repeat those steps from time to time, if it will uncheck automatically again, so keep it in mind.


vs2.jpg (55.7 kB)
vs1.jpg (27.2 kB)
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 326piotrek · Feb 09, 2021 at 09:48 PM

Hi, I know it's been some time, but maybe people are still having this issue.

Solution:

Move all the scripts you want to "see" eachother into the same folder. That fixes the problem everytime.

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 Akunosh · Feb 12, 2021 at 12:23 PM 0
Share

In larger projects I would not want to have all scripts clustered in a sincle folder especielly when external assets come into play. Usually there is a reason why they are sorted the way they are.

  • 1
  • 2
  • ›

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

142 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

Related Questions

UnityVS with VS 2015, CustomEditor classes cant access any game classes 0 Answers

UnityVS with Visual Studio 2015, Editor Scripts cant access game components in VS project file 0 Answers

unity tools for visual studio 2013 Problem 0 Answers

Cant attach debugger | Compile Errors in VS but not in Unity? 0 Answers

Can you script UnityVS's creation of project/solution files? 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