Skip to content

Commit

Permalink
Merge pull request #60 from JasonMa0012/2.x
Browse files Browse the repository at this point in the history
Fix missing icons
  • Loading branch information
JasonMa0012 authored Aug 15, 2024
2 parents 9f9b299 + 4c50234 commit 2438c8b
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 27 deletions.
49 changes: 33 additions & 16 deletions Editor/Helper/Helper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -325,8 +325,9 @@ public static void DrawHelpbox(PropertyStaticData propertyStaticData, PropertyDy
}

private static Texture _logoCache;
private static GUIContent _logoGuiContentCache;
private static Texture _logo => _logoCache = _logoCache ?? AssetDatabase.LoadAssetAtPath<Texture>(AssetDatabase.GUIDToAssetPath("26b9d845eb7b1a747bf04dc84e5bcc2c"));
private static GUIContent _logoGuiContent = new GUIContent(string.Empty, _logo,
private static GUIContent _logoGuiContent => _logoGuiContentCache = _logoGuiContentCache ?? new GUIContent(string.Empty, _logo,
"LWGUI (Light Weight Shader GUI)\n\n"
+ "A Lightweight, Flexible, Powerful Unity Shader GUI system.\n\n"
+ "Copyright (c) Jason Ma");
Expand All @@ -352,21 +353,37 @@ public static void DrawLogo()
private static Material _copiedMaterial;
private static List<string> _copiedProps = new List<string>();

private static Texture _iconCopy = AssetDatabase.LoadAssetAtPath<Texture>(AssetDatabase.GUIDToAssetPath("9cdef444d18d2ce4abb6bbc4fed4d109"));
private static Texture _iconPaste = AssetDatabase.LoadAssetAtPath<Texture>(AssetDatabase.GUIDToAssetPath("8e7a78d02e4c3574998524a0842a8ccb"));
private static Texture _iconSelect = AssetDatabase.LoadAssetAtPath<Texture>(AssetDatabase.GUIDToAssetPath("6f44e40b24300974eb607293e4224ecc"));
private static Texture _iconCheckout = AssetDatabase.LoadAssetAtPath<Texture>(AssetDatabase.GUIDToAssetPath("72488141525eaa8499e65e52755cb6d0"));
private static Texture _iconExpand = AssetDatabase.LoadAssetAtPath<Texture>(AssetDatabase.GUIDToAssetPath("2382450e7f4ddb94c9180d6634c41378"));
private static Texture _iconCollapse = AssetDatabase.LoadAssetAtPath<Texture>(AssetDatabase.GUIDToAssetPath("929b6e5dfacc42b429d715a3e1ca2b57"));
private static Texture _iconVisibility = AssetDatabase.LoadAssetAtPath<Texture>(AssetDatabase.GUIDToAssetPath("9576e23a695b35d49a9fc55c9a948b4f"));

private static GUIContent _guiContentCopy = new GUIContent("", _iconCopy, "Copy Material Properties");
private static GUIContent _guiContentPaste = new GUIContent("", _iconPaste, "Paste Material Properties\n\nRight-click to paste values by type.");
private static GUIContent _guiContentSelect = new GUIContent("", _iconSelect, "Select the Material Asset\n\nUsed to jump from a Runtime Material Instance to a Material Asset.");
private static GUIContent _guiContentChechout = new GUIContent("", _iconCheckout, "Checkout selected Material Assets");
private static GUIContent _guiContentExpand = new GUIContent("", _iconExpand, "Expand All Groups");
private static GUIContent _guiContentCollapse = new GUIContent("", _iconCollapse, "Collapse All Groups");
private static GUIContent _guiContentVisibility = new GUIContent("", _iconVisibility, "Display Mode");
private const string _iconCopyGUID = "9cdef444d18d2ce4abb6bbc4fed4d109";
private const string _iconPasteGUID = "8e7a78d02e4c3574998524a0842a8ccb";
private const string _iconSelectGUID = "6f44e40b24300974eb607293e4224ecc";
private const string _iconCheckoutGUID = "72488141525eaa8499e65e52755cb6d0";
private const string _iconExpandGUID = "2382450e7f4ddb94c9180d6634c41378";
private const string _iconCollapseGUID = "929b6e5dfacc42b429d715a3e1ca2b57";
private const string _iconVisibilityGUID = "9576e23a695b35d49a9fc55c9a948b4f";

private const string _iconCopyTooltip = "Copy Material Properties";
private const string _iconPasteTooltip = "Paste Material Properties\n\nRight-click to paste values by type.";
private const string _iconSelectTooltip = "Select the Material Asset\n\nUsed to jump from a Runtime Material Instance to a Material Asset.";
private const string _iconCheckoutTooltip = "Checkout selected Material Assets";
private const string _iconExpandTooltip = "Expand All Groups";
private const string _iconCollapseTooltip = "Collapse All Groups";
private const string _iconVisibilityTooltip = "Display Mode";

private static GUIContent _guiContentCopyCache;
private static GUIContent _guiContentPasteCache;
private static GUIContent _guiContentSelectCache;
private static GUIContent _guiContentChechoutCache;
private static GUIContent _guiContentExpandCache;
private static GUIContent _guiContentCollapseCache;
private static GUIContent _guiContentVisibilityCache;

private static GUIContent _guiContentCopy => _guiContentCopyCache = _guiContentCopyCache ?? new GUIContent("", AssetDatabase.LoadAssetAtPath<Texture>(AssetDatabase.GUIDToAssetPath(_iconCopyGUID)), _iconCopyTooltip);
private static GUIContent _guiContentPaste => _guiContentPasteCache = _guiContentPasteCache ?? new GUIContent("", AssetDatabase.LoadAssetAtPath<Texture>(AssetDatabase.GUIDToAssetPath(_iconPasteGUID)), _iconPasteTooltip);
private static GUIContent _guiContentSelect => _guiContentSelectCache = _guiContentSelectCache ?? new GUIContent("", AssetDatabase.LoadAssetAtPath<Texture>(AssetDatabase.GUIDToAssetPath(_iconSelectGUID)), _iconSelectTooltip);
private static GUIContent _guiContentChechout => _guiContentChechoutCache = _guiContentChechoutCache ?? new GUIContent("", AssetDatabase.LoadAssetAtPath<Texture>(AssetDatabase.GUIDToAssetPath(_iconCheckoutGUID)), _iconCheckoutTooltip);
private static GUIContent _guiContentExpand => _guiContentExpandCache = _guiContentExpandCache ?? new GUIContent("", AssetDatabase.LoadAssetAtPath<Texture>(AssetDatabase.GUIDToAssetPath(_iconExpandGUID)), _iconExpandTooltip);
private static GUIContent _guiContentCollapse => _guiContentCollapseCache = _guiContentCollapseCache ?? new GUIContent("", AssetDatabase.LoadAssetAtPath<Texture>(AssetDatabase.GUIDToAssetPath(_iconCollapseGUID)), _iconCollapseTooltip);
private static GUIContent _guiContentVisibility => _guiContentVisibilityCache = _guiContentVisibilityCache ?? new GUIContent("", AssetDatabase.LoadAssetAtPath<Texture>(AssetDatabase.GUIDToAssetPath(_iconVisibilityGUID)), _iconVisibilityTooltip);


private enum CopyMaterialValueMask
Expand Down
3 changes: 2 additions & 1 deletion Editor/Helper/RevertableHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,8 @@ private static void DoRevertProperty(MaterialProperty prop, LWGUIMetaDatas metaD
}
}

private static readonly Texture _icon = AssetDatabase.LoadAssetAtPath<Texture>(AssetDatabase.GUIDToAssetPath("e7bc1130858d984488bca32b8512ca96"));
private static Texture _iconCache;
private static Texture _icon => _iconCache = _iconCache ?? AssetDatabase.LoadAssetAtPath<Texture>(AssetDatabase.GUIDToAssetPath("e7bc1130858d984488bca32b8512ca96"));

public static bool DrawRevertButton(Rect rect)
{
Expand Down
16 changes: 7 additions & 9 deletions Editor/ShaderDrawer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -768,7 +768,7 @@ public override void BuildStaticMetaData(Shader inShader, MaterialProperty inPro

public override void DrawProp(Rect position, MaterialProperty prop, GUIContent label, MaterialEditor editor)
{
Stack<MaterialProperty> cProps = new Stack<MaterialProperty>();
var cProps = new Stack<MaterialProperty>();
for (int i = 0; i < 4; i++)
{
if (i == 0)
Expand All @@ -782,27 +782,25 @@ public override void DrawProp(Rect position, MaterialProperty prop, GUIContent l
cProps.Push(p);
}

int count = cProps.Count;
var count = cProps.Count;
var colorArray = cProps.ToArray();
var rect = position; //EditorGUILayout.GetControlRect();

EditorGUI.PrefixLabel(rect, label);
EditorGUI.PrefixLabel(position, label);

for (int i = 0; i < count; i++)
{
EditorGUI.BeginChangeCheck();
var cProp = colorArray[i];
EditorGUI.showMixedValue = cProp.hasMixedValue;
Rect r = new Rect(rect);
var r = new Rect(position);
var interval = 13 * i * (-0.25f + EditorGUI.indentLevel * 1.25f);
float w = EditorGUIUtility.fieldWidth * (0.8f + EditorGUI.indentLevel * 0.2f);
var w = EditorGUIUtility.fieldWidth * (0.8f + EditorGUI.indentLevel * 0.2f);
r.xMin += r.width - w * (i + 1) + interval;
r.xMax -= w * i - interval;

Color src, dst;
src = cProp.colorValue;
var src = cProp.colorValue;
var isHdr = (colorArray[i].flags & MaterialProperty.PropFlags.HDR) != MaterialProperty.PropFlags.None;
dst = EditorGUI.ColorField(r, GUIContent.none, src, true, true, isHdr);
var dst = EditorGUI.ColorField(r, GUIContent.none, src, true, true, isHdr);
if (Helper.EndChangeCheck(metaDatas, cProp))
{
cProp.colorValue = dst;
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "com.jasonma.lwgui",
"version": "1.18.5",
"version": "1.18.6",
"displayName": "LWGUI",
"description": "A Lightweight, Flexible, Powerful Shader GUI System for Unity.",
"keywords": [
Expand Down

0 comments on commit 2438c8b

Please sign in to comment.