Search Unity

CS0246 error (missing type / namespace) of the target class in an Editor class

Discussion in 'Scripting' started by bawenang, Jul 21, 2014.

  1. bawenang

    bawenang

    Joined:
    Aug 18, 2012
    Posts:
    119
    Hi,

    I've got this script that was actually working before but not now:

    Code (CSharp):
    1. [CustomEditor (typeof(GridObject))]
    2. public class GridObjectEditor : Editor {
    3.  
    4.     GridObject gridObj;
    5.  
    6.     public void OnEnable()
    7.     {
    8.         //Settings
    9.         gridObj = (GridObject)target;
    10.         SceneView.onSceneGUIDelegate += this.GridObjectUpdate;
    11.  
    12.  
    13.         gridObj.gameObject.layer = LayerMask.NameToLayer("GridObjectLayer");
    14.  
    15.         SetCollider();
    16.  
    17.  
    18.         //gridObj.transform.localScale = new Vector3(GridMap.gridWidth, GridMap.gridHeight, GridMap.gridHeight);
    19.     }
    20. ...
    21. }
    FYI, the 'GridObject' class is in the "Scripts" folder while the 'GridObjectEditor' class is in the "Editor" folder. I tried rebuilding it and en error saying: "The type or namespace name 'GridObject' could not be found (are you missing a using directive or an assembly reference?) (CS0246) (Assembly-CSharp-Editor)". But the weird part is, it actually worked in the past. I only added some code that doesn't have anything to do with this editor class at all. And when I rebuilt it all, this happens. Why is this happening? Can anybody help me here? Thanks in advance.
     
    Last edited: Jul 21, 2014
  2. bawenang

    bawenang

    Joined:
    Aug 18, 2012
    Posts:
    119
    In the mean time, I'll put the scripts in the "Plugins" folder because AFAIK that "Plugins" are compiled before the "Editor". Which is not entirely correct because these are not scripts for a plugin but the core of the application itself. And it doesn't explain why it worked in the first place.
     
  3. Medding3000

    Medding3000

    Joined:
    Dec 11, 2013
    Posts:
    45
    Should work. There is a bug though where sometimes editor scripts dont recognize non-editor scripts, i have no idea how to 'fix' it.
     
  4. bawenang

    bawenang

    Joined:
    Aug 18, 2012
    Posts:
    119
    Thanks for the reply. That's weird. Has anybody tried reporting the bug?