Search code examples
c#unity-game-enginerider

JetBrains Rider is giving me a "Cannot resolve symbol" error on some Unity elements, though the script compiles and runs


When trying to create a custom inspector I get the Cannot resolve symbol errors until through "context actions" I tell it to reference the assembly UnityEditor.CoreModule v0.0.0.0 and import UnityEditor.whatever symbol I clicked on. I tried putting some images here, but that requires reputation.

[CustomEditor(typeof(Spider))] <- Cannot resolve symbol "CustomEditor"
public class SpiderEditor : Editor <- Cannot resolve symbol 'Editor'
{
    public override void OnInspectorGUI() <- almost everything else has the same error
    {
        base.OnInspectorGUI();
        EditorGUILayout.Space(10);
        Spider s = (Spider)target;
        EditorGUILayout.CurveField(s.redLight, new Color(1, 0.15f, 0.15f), new Rect(0, 0, 150, 1));
    }
}

These errors seem to be an error with the IDE, as it compiles just fine.

Additional info in case it is relevant:

  • Rider version is 2022.2.3, and I have seen this bug across other versions.
  • Unity version is 2021.2.17f1, and I have also seen this across other unity versions.
  • My OS is Windows 10.
  • The bug is consistent, I don't recall ever not having this issue when using CustomEditors.

One solution I found told me to disable "Use ReSharper Build", which seems to have made the script compile way faster for some reason, but the issue remains.

As this has happened many times, I doubt restarting my PC or any apps would solve it. I also haven't found many useful results when trying to google the issue.


Solution

  • It turns out I just needed to put the script inside a "Assets/Editor/" folder. No idea why it caused that weirdness. ¯\_(ツ)_/¯