Skip to content
This repository has been archived by the owner on Oct 31, 2023. It is now read-only.

Commit

Permalink
LTS v1.0.3 UI fixes
Browse files Browse the repository at this point in the history
Fixed #189 toolbar not showing up introduced in f82311c (v1.0.3)
Improved GUISkin handling so that the default GUIStyle are always used
	- Fixes some problems with missing styles at Runtime if not explicitly set, as well as issues when switching between dark and light modes
	- New behaviour: Always generate DefaultSkin and save to file for user to copy and modify. If OverriddenSkin.asset exists, use that style as a basis instead.
Fixed issue with XML IO for objects that can not be serialized (e.g. Texture2D in TextureCompose example)
  • Loading branch information
Seneral committed Jun 22, 2020
1 parent b31fa9b commit 768b0e6
Show file tree
Hide file tree
Showing 7 changed files with 40 additions and 2,214 deletions.
7 changes: 1 addition & 6 deletions Editor/NodeEditorWindow.cs
Original file line number Diff line number Diff line change
Expand Up @@ -267,12 +267,7 @@ private void OnGUI()
}

// Draw Interface
float screenWidth = Screen.width;
#if UNITY_EDITOR && UNITY_2019_3_OR_NEWER
float scaling = UnityEditor.EditorPrefs.GetInt("CustomEditorUIScale") / 100.0f;
screenWidth = screenWidth / scaling;
#endif
editorInterface.DrawToolbarGUI(new Rect(0, 0, screenWidth, 0));
editorInterface.DrawToolbarGUI();
editorInterface.DrawModalPanel();

// End Node Editor GUI
Expand Down
54 changes: 30 additions & 24 deletions Runtime/Framework/Interface/NodeEditorGUI.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,35 +32,40 @@ public static partial class NodeEditorGUI

public static bool Init ()
{
List<GUIStyle> customStyles = new List<GUIStyle> ();
overrideSkin = ResourceManager.LoadResource<GUISkin> ("OverrideSkin.asset");
if (overrideSkin == null)
{ // Create default skin from scratch
if (!CreateDefaultSkin ()) return false;
overrideSkin = Object.Instantiate (defaultSkin);
}
else
{ // Use override
overrideSkin = Object.Instantiate (overrideSkin);
}

// Copy default styles in current setting, modified to fit custom style
// This mostly refers to the editor styles

defaultSkin = ResourceManager.LoadResource<GUISkin> ("DefaultSkin.asset");
if (defaultSkin == null)
return CreateDefaultSkin();
else {
defaultSkin = Object.Instantiate (defaultSkin);
// Copy default editor styles, modified to fit custom style
customStyles = new List<GUIStyle> (defaultSkin.customStyles);
foreach (GUIStyle style in GUI.skin.customStyles)
List<GUIStyle> customStyles = new List<GUIStyle> (overrideSkin.customStyles);
foreach (GUIStyle style in GUI.skin.customStyles)
{
if (overrideSkin.FindStyle(style.name) == null)
{
if (defaultSkin.FindStyle(style.name) == null)
GUIStyle modStyle = new GUIStyle (style);
if (modStyle.normal.background == null)
{
GUIStyle modStyle = new GUIStyle (style);
if (modStyle.normal.background == null)
{
modStyle.fontSize = defaultSkin.label.fontSize;
modStyle.normal.textColor = modStyle.active.textColor = modStyle.focused.textColor = modStyle.hover.textColor = defaultSkin.label.normal.textColor;
}
customStyles.Add (modStyle);
modStyle.fontSize = overrideSkin.label.fontSize;
modStyle.normal.textColor = modStyle.active.textColor = modStyle.focused.textColor = modStyle.hover.textColor = overrideSkin.label.normal.textColor;
}
customStyles.Add (modStyle);
}
defaultSkin.customStyles = customStyles.ToArray();

Background = ResourceManager.LoadTexture ("Textures/background.png");
AALineTex = ResourceManager.LoadTexture ("Textures/AALine.png");

return Background && AALineTex;
}
overrideSkin.customStyles = customStyles.ToArray();

Background = ResourceManager.LoadTexture ("Textures/background.png");
AALineTex = ResourceManager.LoadTexture ("Textures/AALine.png");

return Background && AALineTex;
}

public static bool CreateDefaultSkin ()
Expand Down Expand Up @@ -177,7 +182,8 @@ public static bool CreateDefaultSkin ()

defaultSkin.customStyles = customStyles.ToArray();
#if UNITY_EDITOR
UnityEditor.AssetDatabase.CreateAsset(Object.Instantiate (defaultSkin), ResourceManager.resourcePath + "DefaultSkin.asset");
if (!ResourceManager.resourcePath.StartsWith("Packages"))
UnityEditor.AssetDatabase.CreateAsset(Object.Instantiate (defaultSkin), ResourceManager.resourcePath + "DefaultSkin.asset");
#endif

return true;
Expand Down
Loading

0 comments on commit 768b0e6

Please sign in to comment.