UnityEditor.UI reference missing

I’m trying to extend the ButtonEditor class to make my own custom editor but I can’t access the UnityEditor.UI namespace. It seems that the problem is a missing reference. If I go into the MonoDevelop project and manually add a reference to the UnityEditor.UI.dll then it works, however if I Sync the MonoDevelop project again the reference is removed. Is there a way to add the reference within Unity so that it won’t be removed by re-syncing.

I had the same problem under Unity 5. Basically the reference to UnityEditor.UI.dll is not being added to the editor project.

I reported this as a bug cause I think this DLL should be included for those who extends the editor classes found in UnityEditor.UI.dll

The solution (for now) is to create a .csproj.user and add the reference in it. When Unity does a sync it will update the .csproj but leave your .csproj.user alone.

I use Visual Studio and it will also load info from the csproj.user. I guess MonoDevelop would support this too.

The file you want to add will be named “Assembly-CSharp-Editor-vs.csproj.user” and perhaps Assembly-CSharp-Editor.csproj.user - just look at what the project is named that contains the source which needs the reference.

Included this alongside the solution file and the other project files of the project. Normally one this is one directory up from where your project /Assets/ folder is.

Add this. Fix the Path if you installed Unity somewhere else or are on OSX.

<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="12.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
	<ItemGroup>
		<Reference Include="UnityEditor.UI">
			<HintPath>C:/Program Files/Unity/Editor/Data/UnityExtensions/Unity/GUISystem/Editor/UnityEditor.UI.dll</HintPath>
		</Reference>
	</ItemGroup>
</Project>

All editor related scripts should be placed into “Editor” directory anywhere in the project, apparently.

You can’t use the built-in UnityEditor.UI, but you can download (or just copy-paste) the needed classes from the repository.

I found my self needing a modified Text editor, and just copied the GraphicEditor, which the original TextEditor is derived from, into the project. Then I copy-pasted the TextEditor code and modified it as needed. Works like a charm.

You can just copy UnityEditor.UI.dll file under the directory …Unity\Editor\Data\UnityExtensions\Unity\GUISystem\Editor to Assets floder of the project.
It works for me with the Unity version 2017.1.1 f1.

Don’t think you should be using the new uGUI to create an editor window.

Try using something like this (from my Alchemy items menu)

using UnityEngine;
using UnityEditor;
using System.Collections;

public class CreateAlchemyItem : EditorWindow {

	[MenuItem("Alchemy/Create Item")]

using UnityEditor; is what you’re after.