How can i fix the error code CS0246?

Hello everyone:)

I’m really annoyed with this problem…

Here is the error:

Assets/TypeOut/Scripts/TypeOutEditor.cs(2,7): error CS0246: The type or namespace name `UnityEditor’ could not be found. Are you missing a using directive or an assembly reference?

Assets/TypeOut/Scripts/TypeOutEditor.cs(3,7): error CS0246: The type or namespace name `UnityEditorInternal’ could not be found. Are you missing a using directive or an assembly reference?

Script:

using UnityEngine;
using UnityEditor;
using UnityEditorInternal;
using System;

[CustomEditor(typeof(TypeOutScript))]
public class TypeOutEditor : Editor {

private string ontxt = "Turn On";

private SerializedObject TOS;
private SerializedProperty finalText;
private SerializedProperty On;
private SerializedProperty Reset;
private SerializedProperty TotalTypeTime;
private SerializedProperty TypeRate;
private SerializedProperty RandomCharacterChangeRate;

enum TimeModes {TotalTime = 0, TypeRate =1};
TimeModes TM = TimeModes.TotalTime;
private float Time = 0.5f;
private float RCCR = 0.1f;

public void OnEnable()
{
	if (target == null)
	{
		return;
	}

	TOS = new SerializedObject(target);
	finalText = TOS.FindProperty("FinalText");
	On = TOS.FindProperty("On");
	Reset = TOS.FindProperty("reset");
	TotalTypeTime = TOS.FindProperty("TotalTypeTime");
	TypeRate = TOS.FindProperty("TypeRate");
	RandomCharacterChangeRate = TOS.FindProperty("RandomCharacterChangeRate");
}

public override void OnInspectorGUI() 
{
	TOS.Update();

	finalText.stringValue = ParseNewline(finalText.stringValue.Trim());

// EditorGUILayout.PropertyField(On);
// EditorGUILayout.PropertyField(Reset);

	EditorGUILayout.BeginHorizontal ();

	if(GUILayout.Button(ontxt))
	{
		if (On.boolValue == true)
		{
			On.boolValue = false;
			ontxt = "Turn On";
		}
		else
		{
			On.boolValue = true;
			ontxt = "Turn Off";
		}
	}

	if (On.boolValue == true)
	{
		ontxt = "Turn Off";
	}
	else
	{
		ontxt = "Turn On";
	}

	if(GUILayout.Button("Reset"))
	{
		Reset.boolValue = true;
	}

	EditorGUILayout.EndHorizontal ();

	EditorGUILayout.Space();

// GUI.Label(new Rect(0, 40, 100, 40), GUI.tooltip);
EditorGUILayout.LabelField(“FinalText:”);
EditorGUILayout.LabelField(“note: ’
’ for new line”);
EditorGUILayout.PropertyField(finalText, GUIContent.none,GUILayout.Height(50));

	EditorGUILayout.Space();

	EditorGUILayout.BeginHorizontal ();

	TM = (TimeModes) EditorGUILayout.EnumPopup(TM);

	if (TM == TimeModes.TotalTime)
	{
		Time = EditorGUILayout.Slider(Time,0f, 10f);
		TotalTypeTime.floatValue = Time;
	}
	else
	{
		Time = EditorGUILayout.Slider(Time,0f, 1f);
		TotalTypeTime.floatValue = -1f;
		TypeRate.floatValue = Time;
	}
	EditorGUILayout.EndHorizontal ();

	EditorGUILayout.Space();

	EditorGUILayout.LabelField("Random Character Change Rate");

	RCCR = EditorGUILayout.Slider(RCCR,0f, 1f);
	RandomCharacterChangeRate.floatValue = RCCR;

	TOS.ApplyModifiedProperties();

}

private string ParseNewline(string s)
{
	s = s.Replace("\

“,”|");

	string[] SS = s.Split('|');
	
	string ReturnString = "";
	
	foreach (string rp in SS)
	{
		ReturnString = ReturnString + rp + "

";
}

	return ReturnString;
}

}

Pls help and describe detailed:)

It makes sense that you would receive this error when trying to create builds. Any script that uses UnityEditor should either use preprocessor directives for UNITY_EDITOR or be places in an Editor Folder.

If you are receiving this error when trying to run in the editor it is possible that your solution has been corrupted or is not being properly referenced. I would recommend deleting all the generated csproj files and solution (sln) file from your project folder. The next time you open Unity it should regenerate those files with the appropriate references.

By the looks of it …

[CustomEditor(typeof(TypeOutScript))]

…it is an editor script so it should be placed in a folder called ‘Editor’ anywhere in your project as instructed in many answers already