using UnityEditor;
using UnityEditor.Experimental;
using UnityEngine;
using System.Reflection;
using System.Collections.Generic;
[InitializeOnLoad]
public static class FontLoader
{
private const string FONT = "Dejavu Sans Mono";
private const string FONTPATH = "Fonts/dejavu.ttf";
static FontLoader()
{
var font = EditorResources.Load<Font>(FONTPATH) as Font;
var fontField = typeof(EditorResources).GetField("s_NormalFont", BindingFlags.Static | BindingFlags.NonPublic);
fontField.SetValue(null, font);
GUISkin defaultSkin = GUIUtility.GetDefaultSkin();
defaultSkin.font = font;
EditorResources.UpdateGUIStyleProperties(defaultSkin);
}
}
actually half of it was not necessary, you don’t get the selector in menu, but it does its job /shrug
Can you also just overwrite the font in the Console window, but keep the font of other UI untouched, for example? I always wanted a mono-space font for the console.
Managed to override almost every element. Everything that’s still bright is using the light skin because they are using an icon/image as the background. Trying to override the icons with the Editor Default Resources folder isn’t working. A fair amount of the UI uses these images, mainly the Profiler.
I can’t figure out a way to replace a single element font sadly. Actually i can’t even change a lot of elements since none of the selectors i tried work, i wonder how @Grimreaper358 did it.
It seems that a lot of uss properties get just flat out ignored. It seems there are inconsistencies between uss to imgui styles.
Yea, I was planning to do this after I got it to a decent state and would only have minor fixes to do.
The last few major things I need to do is replace the icons and fix some broken windows that use a separate/their own theme. For the icons contributing to the light theme still, I will have to remake or wait and see if they will add the editor resources to GitHub and use/modify those. As for how I edit the UI, I just followed the steps from the other thread which you also linked “Basic how-to” (After a while I converted it a package, this way it’s easily shared and updated)
Also for some reason, Unity stopped auto-reloading the file so every change I make I have to close the editor and reopen which increases the iterating time a lot. Especially since some element names don’t really do anything when you try to edit them (If anyone knows a fix let me know, also how to replace the icons. Followed the steps by the dev but it didn’t work)
Broken Windows - Not 100% sure how to fix so far
Package Manager - Has it’s own UI so I will have to see if I can override its properties in the same file
If you know the paths to the resources, you could rip them using EditorGUIUtility.Load, Instantiate and AssetDatabase.CreateAsset. Redistributing them wouldn’t be necessary either since you could just distribute an editor script to rip them on the user’s side. The resource paths can probably be found in the built-in .uss files, which can be obtained using my script linked in the OP.
I was thinking of going back and looking at your script to see if I could get some information from it. Unfortunately, I don’t really know much about coding so I’m kind of limited there. I’m not even 100% sure how to use the script you made so ripping the assets using the libraries? listed above is slightly out of my reach in terms of knowledge. I just know a bit of web development so it wasn’t any problem restyling the editor so far.
If you just need a simple step-by-step instruction on how to get it running:
Make a new folder in your Assets directory, call it whatever you want
In the editor, right click inside that folder and go Create → Assembly Definition
Name the assembly definiton Assembly-CSharp-Editor-testable
Create a new script in the folder, call it StyleSheetExporter
Open the script in a text editor, delete everything and paste my code in
Upon a refresh, you should have a new “StyleSheet Exporter” dropdown in the editor.
When you run it, it’ll save all the files into your project directory, just outside the Assets folder.