- Home /
Strange problem with CustomEditor
I have a problem with custom editor, becouse my script dont recognize the main script.
using UnityEngine;
using UnityEditor;
using System.Collections;
[CustomEditor (typeof(audioReverbScript))]
public class audioReverbEditor : Editor
{
public enum presetNames
{
Off = 1,
Generic = 2,
PaddedCell = 3,
Room = 4,
Bathroom = 5,
Livingroom = 6
}
private int number;
private presetNames myPresetNameItemType = presetNames.Off;
public audioReverbScript script;
public void OnEnable()
{
script = (audioReverbScript) target;
}
public override void OnInspectorGUI()
{
GUI.changed=false;
myPresetNameItemType = (presetNames)EditorGUILayout.EnumPopup("Wybierz preset: ", myPresetNameItemType );
script.presetNumber=(int) myPresetNameItemType;
if(GUI.changed) EditorUtility.SetDirty(script);
}
}
And that's the error
Assets/Plugins/Editor/audioReverbEditor.cs(23,16): error CS0246: The type or namespace name `audioReverbScript' could not be found. Are you missing a using directive or an assembly reference?
Another reason why this could be happening is if audioReverbEditor.cs is inside the Plugins folder (which is a special folder) but audioReverbScript.cs is outside of it: scripts in the Plugins folder and subfolders can only communicate with other scripts inside Plugins.
But all the tutorials about CustomEditor say to do so and they don't have this problem. And I didn't have this issue before.
Answer by Demigiant · Oct 03, 2012 at 05:39 PM
It seems that you simply don't have any audioReverbScript class in your project. Considering that code is case-sensitive, maybe it's AudioReverbScript?
Nope, the script is ok and the code too. I had to move Editor folder outside another folder of my game project.
Oh that's very strange. I always keep my Editor folders inside other folders, and it works. Can I ask what version of Unity are you using, and on what platform?
Answer by Bunny83 · Oct 17, 2020 at 11:28 AM
Since the question was bumped already...
You have to be careful with special folders names. The plugins subfolder belongs to a seperate compilation group that is compiled before the rest of your game code. In essence things in the plugins folder can't access anything outside the plugins folder. So if you have the editor script inside the plugins folder, your "audioReverbScript" should be inside the plugins folder as well.
ps: You really shouldn't start type names with a lower case letter. Type names in C# and Unity generally start with a capital letter and follow PascalCase. Same goes for method names. I just added this for general guidance as the OP hasn't been online for the last 5 years.
Your answer
![](https://koobas.hobune.stream/wayback/20220613081827im_/https://answers.unity.com/themes/thub/images/avi.jpg)