Hi everyone!! I am having a strange problem that I do not know why it is and I have noticed that it happens to me under versions of Unity 2019 and VS 2019. In previous versions of Unity this problem did not happen to me.
I create a class called Controller in a file (Controller.cs) and its custom Inspector called ControllerEditor in a file (ControllerEditor.cs).
Intellisense does not recognize the Controller class from the ControllerEditor.cs script.
It always tells me that “The type or namespace name (Controller) was not found. Missing a directive or an assembler reference?”.
The ControllerEditor.cs script is inside a folder called Editor as usual … and the two classes have the same namespace.
Even though VisualStudio 2019 is telling me this error, Unity does not give me errors by console and all the logic of the customInspector works well …
Do you know why this problem may be happening? If I remove the ControllerEditor.cs script from the Editor folder, the problem is solved. But isn’t there not always to put the “customInspector” scripts inside folders called Editor? Has this changed in Unity 2019? In the Unity 2019 documentation I have not found whether it is mandatory to put the customInspector scripts in folders called “Editor”.
Can anybody help me?
@spryx Thanks for the reply!
They have the same namespace. And as I said it only happens to me with Unity 2019.3 onwards. The same code with Unity 2018 doesn’t happen, so I assume the code is fine.
the code can be something like this:
namespace _3MBJ_Productions.NextGenInteractionSystem
{
public class InteractionsSystemManager : MonoBehaviour{....}
}
namespace _3MBJ_Productions.NextGenInteractionSystem
{
[CustomEditor(typeof(InteractionsSystemManager))]
[CanEditMultipleObjects]
public class InteractionsSystemManagerInspector : Editor
{
InteractionsSystemManager ISM;
}
}
Here in the photo it is seen how Intelliesense gives an error although Unity does not throw these errors by console and everything works well:
That is weird behavior for sure. I just realized I don’t assign namespaces to my editor scripts.
Is it possible to use the fully qualified namespace for the editor script? (the target) Without seeing the project folder structure it is difficult to determine.
Hi @spryx !!!
I don’t know what you mean by this: “Is it possible to use the fully qualified namespace for the editor script?”
the scripts are in the following path:
Assets/3MBJ Productions/NextGen_InteractionSystem/Scripts/InteractionSystemManager/InteractionSystemManager.cs
y
Assets/3MBJ Productions/NextGen_InteractionSystem/Scripts/InteractionSystemManager/Editor/InteractionSystemManagerInspector.cs
Try to delete all the .csproj and .sln files in your project folder and let unity rebuild them. Does it automatically on the next recompile or restart.
Never used an Editor folder for my inspectors. Does it leave it out of the builds automatically then?
Try leaving your inspector scripts in the same folder and use #if UNITY_EDITOR #endif.
This has not solved the problem. So I still don’t know why this problem occurs … I guess Unity 2019 no longer needs these “CustomEditor” scripts to be inside a folder called “Editor”, but in the documentation I couldn’t find any information.
Regarding the question of whether “Does it leave it out of the builds automatically then?”, I don’t know how to check this …
Any information would come in handy from someone on the Unity team to clarify this.