Building a game with an Editor extending class

Hello. I recently got a pretty annoying issue. I have a class that extends Editor:

static class GetSelection extends Editor{

}

When I try to build the game, the console says that it can’t be built because of compiler error and throws this error:

The name 'Editor' does not denote a valid type ('not found').

How can I bypass this error ?

Use editor classes to edit game relevant classes not as a game class

Yes, I’m not using it as a game class. I’m using this class only in the editor, never in the game.

Is this class in a directory called Editor? You need to make sure all editor classes are in a directory called editor so unity does not include them when it builds.

Karl

It’s not in the editor folder, but if I put it there, those lines here (from another script):

if(Application.isEditor){
		var selected : Transform = GetSelection.Transform();
		
		if(smooth  selected != lastSelected){
			if(selected) smoothLeaderlastPos = selected.localPosition;
			lastSelected = selected;
		}
	
			if(smooth  selected){
				if(smoothLeaderlastPos != selected.localPosition)SmoothMovePoints(dampDirection, selected);
			}
	}

Won’t work. It would say “Unknown identifier: ‘GetSelection’.”

Make sure all classes that use Editor classes are in a directory called Editor. It sounds like your other script needs to be in the Editor folder as well.

Karl

In this situation, you wouldn’t use Application.isEditor. A preprocessor directive #if UNITY_EDITOR is needed.