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:
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…
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?
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
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;
}
}
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…