mirror of
https://github.com/codewriter-packages/Tri-Inspector.git
synced 2025-01-22 00:08:51 -05:00
Fix incorrect display of textures during manual installation in Assets directory (#99)
This commit is contained in:
parent
42413a7a68
commit
9bb0c1611c
@ -5,30 +5,41 @@ namespace TriInspector
|
||||
{
|
||||
public static class TriEditorStyles
|
||||
{
|
||||
private const string BaseResourcesPath = "Packages/com.codewriter.triinspector/Editor/Resources/";
|
||||
|
||||
private static GUIStyle _contentBox;
|
||||
private static GUIStyle _box;
|
||||
|
||||
|
||||
public static GUIStyle TabOnlyOne { get; } = "Tab onlyOne";
|
||||
public static GUIStyle TabFirst { get; } = "Tab first";
|
||||
public static GUIStyle TabMiddle { get; } = "Tab middle";
|
||||
public static GUIStyle TabLast { get; } = "Tab last";
|
||||
|
||||
|
||||
private static GUIStyle FallbackContentBox { get; } = "HelpBox";
|
||||
private static GUIStyle FallbackBox { get; } = "HelpBox";
|
||||
|
||||
public static GUIStyle ContentBox
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_contentBox == null)
|
||||
{
|
||||
_contentBox = new GUIStyle
|
||||
var backgroundTexture = LoadTexture("TriInspector_Content_Bg");
|
||||
|
||||
if (backgroundTexture == null)
|
||||
{
|
||||
border = new RectOffset(2, 2, 2, 2),
|
||||
normal =
|
||||
_contentBox = new GUIStyle(FallbackContentBox);
|
||||
}
|
||||
else
|
||||
{
|
||||
_contentBox = new GUIStyle
|
||||
{
|
||||
background = LoadTexture("TriInspector_Content_Bg"),
|
||||
},
|
||||
};
|
||||
normal =
|
||||
{
|
||||
background = backgroundTexture,
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
_contentBox.border = new RectOffset(2, 2, 2, 2);
|
||||
}
|
||||
|
||||
return _contentBox;
|
||||
@ -41,14 +52,24 @@ namespace TriInspector
|
||||
{
|
||||
if (_box == null)
|
||||
{
|
||||
_box = new GUIStyle
|
||||
var backgroundTexture = LoadTexture("TriInspector_Box_Bg");
|
||||
|
||||
if (backgroundTexture == null)
|
||||
{
|
||||
border = new RectOffset(2, 2, 2, 2),
|
||||
normal =
|
||||
_box = new GUIStyle(FallbackBox);
|
||||
}
|
||||
else
|
||||
{
|
||||
_box = new GUIStyle
|
||||
{
|
||||
background = LoadTexture("TriInspector_Box_Bg"),
|
||||
},
|
||||
};
|
||||
normal =
|
||||
{
|
||||
background = backgroundTexture,
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
_box.border = new RectOffset(2, 2, 2, 2);
|
||||
}
|
||||
|
||||
return _box;
|
||||
@ -57,10 +78,14 @@ namespace TriInspector
|
||||
|
||||
private static Texture2D LoadTexture(string name)
|
||||
{
|
||||
var path = EditorGUIUtility.isProSkin
|
||||
? BaseResourcesPath + name + "_Dark.png"
|
||||
: BaseResourcesPath + name + ".png";
|
||||
|
||||
name = EditorGUIUtility.isProSkin ? $"{name}_Dark" : name;
|
||||
|
||||
var results = AssetDatabase.FindAssets($"{name} t:texture2D");
|
||||
|
||||
if (results.Length == 0) return null;
|
||||
|
||||
var path = AssetDatabase.GUIDToAssetPath(results[0]);
|
||||
|
||||
return (Texture2D) EditorGUIUtility.Load(path);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user