Custom Inspector Internal Compiler Error

This is my first time making a Custom Inspector and it’s giving me an “Internal Compiler Error” with a basically empty Editor file. It’s placed in the Assets/Editor folder:

using UnityEngine;
using UnityEditor;
using System.Collections;

[CustomEditor(typeof(generator))]

public class GenEditor : Editor {


	public override void OnInspectorGUI() {

		generator myTarget = (generator) target;


	}

}

Is it something to do with the script it’s referencing or some kind of link I haven’t set up in Unity? Here’s the debug log:

One Bump, this is really giving me a hard time, I know I’m missing something…

Last Bump, please help! Anything you know might help.

If you post a dropbox download containing a minimal example project which exhibits this issue, I would be happy to take a quick look for you.

Well, it’s happening on everything. It’s not specific to any script. It seems the set up code I posted above or some dynamic link has gone awry. So the set-up code above is all I can really give you…

I apparently was missing some of the error log

Without a simple project which reproduces the problem I am not going to be able to help.

Can you post the script that this Custom Editor is for? Looking at both would be helpful.

using UnityEngine;
using UnityEditor;
using System.Collections;

public class generator : MonoBehaviour {
public int x = 0;

void Start(){
 DoSomething();
}

DoSomething() {
x = 1;
}
}

There’s no common occurrences of internal compiler errors when setting up custom editors?

So just looking at you script the issue I see is that you’re calling

generator myTarget = (generator) target;

but “generator” is never declared.

Also you’re calling CustomEditor(typeof(generator)). Is the class you’re trying to edit called generator with a little g?

edit:
NM, read that wrong. Lemme copy those down and I’ll check them out.

This script, plus that editorscript in assets/editor gives me an internal compiler error, and any other script I could create that I reference gives me the same thing. It doesn’t seem as if the script matters at all.

It’s giving me .x in my autocomplete list when I go to reference myTarget. So it seems as if it’s linking correctly in Monodevelop. Yes, the names are correct, is there a way I should be “declaring” a script in the beginning of my editor? Like I said I’m new to Custom Editors, as far as I know “generator” doesn’t need to be declared, as it’s referencing an existing script, not a variable.

The only thing which springs to my mind with this limited information is that your script name differs from your class name… I have known this to cause issues in the past. Your script files should be named “Assets/generator.cs” and “Assets/Editor/GenEditor.cs”.

I moved the file out of the editor file just to see what the debug log, and it mentions ensuring that the script being referenced is derived from a scriptableobject, could this be the problem? I’m not entirely sure how to go about that but I’m gonna look now while I wait for answers :stuck_out_tongue:

Well usually you want to cache a reference to it for later on like so:

using UnityEngine;
using UnityEditor;
using System.Collections;

[CustomEditor(typeof(generator))]
public class GenEditor : Editor {
    generator myTarget;

    void OnEnable () {
        myTarget = (generator)target;
    }
    
    public override void OnInspectorGUI() {
        generator myTarget = (generator) target;
    }
    
}

It worked fine for me with one minor change, your DoSomething wasn’t set up as a method:

using UnityEngine;
using UnityEditor;
using System.Collections;

public class generator : MonoBehaviour {
    int x = 0;
    
    void Start(){
        DoSomething();
    }
    
    void DoSomething() {
        x = 1;
    }
}

With that change it worked fine for me.

It’s definitely not the names, I double,triple,quadruple check them and then some.

Wait, is the generator file in an Editor folder? It shouldn’t be, only the GenEditor file should go in an Editor folder.

Ah, I missed that with that particular script example, but changing it didn’t fix it for me, which confirms what I thought, there’s something wrong with my Unity-Monodevelop dynamic linking. Thanks for the help guys.

This is driving me nuts… So now it seems that any script I place in Assets/Editor is giving me an internal compiler error. Is there anyone who knows why this would happen? I’m talking any script… Js,boo,c#, any contents, any derivation. If it’s a script I get an Internal Compiler Error…