4
\$\begingroup\$

The strange thing is that opened scripts or newly opened ones are working fine. It's the new created C# scripts that are not working.

With not working, I mean the MonoBehaviour is not in light blue color it's in black color. In this screenshot I took, I marked it with a red circle.

Not light blue

What have I tried so far? I have closed Visual Studio and started over again. Since it didn't solve it, I closed the unity editor and started it over again, to no avail.

I pressed 'clean solution', I pressed 'rebuild solution', I pressed 'build solution'.

What else can I do ? And why are the other scripts working fine? If I type gameo...it will auto complete it to GameObject but in this specific script it's just not working.

This is a screenshot of the editor. I have in the Hierarchy a Ladder object. In the Assets I created a folder name Ladder and a script name Ladder. But this Ladder script is not working.

Editor

This is the Ladder script and this script was working before but once I created another script inside the ladder folder name Raise empty script the Raise script didn't work and now the Ladder is not working either. But other scripts are working fine.

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class Ladder : MonoBehaviour
{
    public Transform charcontroller;

    private bool inside = false;
    private float heightFactor = 3.2f;

    private void OnTriggerEnter(Collider other)
    {
            inside = true;
    }

    private void OnTriggerExit(Collider other)
    {
            inside = false;
    }

    private void Update()
    {
        if (inside == true && Input.GetKey("w"))
            charcontroller.transform.position += Vector3.up / heightFactor;
    }
}
\$\endgroup\$
5
\$\begingroup\$

The Solution shows that script under "Miscellaneous Files" This suggests that it hasn't been added to the project. Try manually adding it via the Project menu or dragging it into the appropriate area in your Project Explorer pane.

\$\endgroup\$
  • 1
    \$\begingroup\$ I didn't see the "Miscellaneous Files". Anyway i solved it with this steps: Go to the file inside Solution Explorer. Right-Click file and select Exclude from project. Right-Click your project/folder where the file was and click add Existing Item, and add the file you just removed back into your project. But i still wonder why it happened and if it will happen again. A bit annoying. \$\endgroup\$ – Daniel Lip Nov 3 '17 at 1:52
  • 2
    \$\begingroup\$ @DanielLip if this solved your problem, it's best to post it as an Answer and mark it Accepted. This makes it easier for other developers experiencing the same issue to find your solution. \$\endgroup\$ – DMGregory Nov 3 '17 at 2:44
  • \$\begingroup\$ Why does this even happen? Yesterday I had no problems at all, and now everything is messed up and any new or moved file get miscellaneous \$\endgroup\$ – Black Nov 7 '17 at 11:58
4
\$\begingroup\$

All you have to do is click on the assets folder in your solution explorer and click on the refresh button.

\$\endgroup\$
  • \$\begingroup\$ Worked like a charm. Wonder why there isn't a fix though \$\endgroup\$ – Tosh Nov 29 '18 at 5:34
2
\$\begingroup\$

I get this all the time. Right-clicking on the project in solution explorer and selecting Unload project and then Reload project works for me

\$\endgroup\$
2
\$\begingroup\$

This is currently a general bug on pending release. Please have look at this : https://developercommunity.visualstudio.com/content/problem/130597/unity-intellisense-not-working-after-creating-new-1.html

For some poeple unloading and loading project is not working. For me, currently I'm creating my scripts inside Visual Studio via Unity Project Explorer window( View - Unity Project Explorer) which sees the script as a part of the solution.

\$\endgroup\$
2
\$\begingroup\$

When you modify a project with an external tool (explorer or unity or whatever) vs needs to reload the project. Sometimes unity doesn't trigger the automatic reload process and you either have to restart vs and unity or reload the project in vs manually.

\$\endgroup\$
  • \$\begingroup\$ How to manually reload the project in VS? \$\endgroup\$ – Black Nov 8 '17 at 12:56
  • 1
    \$\begingroup\$ In solution explorer, right click on the project -> Unload, then right click on the same project -> reload \$\endgroup\$ – Alakanu Nov 8 '17 at 14:06
  • \$\begingroup\$ @user1662292 already wrote that in a answer, you might as well choose his if it works \$\endgroup\$ – Alakanu Nov 8 '17 at 14:07
1
\$\begingroup\$

I solved it with this steps: Go to the file inside Solution Explorer. Right-Click file and select Exclude from project. Right-Click your project/folder where the file was and click add Existing Item, and add the file you just removed back into your project.

\$\endgroup\$
0
\$\begingroup\$

None of the above worked for me. What did work for me was to Add a new dummy class to the folder (example: "DeleteMe"). Then try to reference that new dummy class somewhere.

When I did this, Intellisense actually saw this dummy class (when it wasn't seeing any of my existing classes). After this, I was able to access the original class I was trying to reference. Just make sure you delete the dummy class you created.

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.