Skip to content

Commit

Permalink
fix label missing when Tex() has no extra prop #44
Browse files Browse the repository at this point in the history
  • Loading branch information
JasonMa0012 committed Nov 24, 2023
1 parent e634f34 commit 580cbfc
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 8 deletions.
14 changes: 7 additions & 7 deletions Editor/ShaderDrawer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -662,8 +662,6 @@ public override void DrawProp(Rect position, MaterialProperty prop, GUIContent l
{
EditorGUI.showMixedValue = prop.hasMixedValue;
var rect = position;
var texLabel = label.text;
// label.text = " ";

MaterialProperty extraProp = lwgui.perFrameData.GetProperty(_extraPropName);
if (extraProp != null && (
Expand All @@ -672,18 +670,20 @@ public override void DrawProp(Rect position, MaterialProperty prop, GUIContent l
))
{
var i = EditorGUI.indentLevel;
RevertableHelper.FixGUIWidthMismatch(extraProp.type, editor);
EditorGUI.indentLevel += 2;
EditorGUI.indentLevel = 0;

var extraRect = MaterialEditor.GetRightAlignedFieldRect(rect);
extraRect.height = rect.height;

if (extraProp.type == MaterialProperty.PropType.Vector)
_channelDrawer.OnGUI(rect, extraProp, label, editor);
_channelDrawer.OnGUI(extraRect, extraProp, GUIContent.none, editor);
else
editor.ShaderProperty(rect, extraProp, label);
editor.ShaderProperty(extraRect, extraProp, GUIContent.none);

EditorGUI.indentLevel = i;
}

editor.TexturePropertyMiniThumbnail(rect, prop, string.Empty, label.tooltip);
editor.TexturePropertyMiniThumbnail(rect, prop, label.text, label.tooltip);

EditorGUI.showMixedValue = false;
}
Expand Down
17 changes: 17 additions & 0 deletions Editor/Test/LWGUI_SampleDrawer 2.mat
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,14 @@ Material:
m_SavedProperties:
serializedVersion: 3
m_TexEnvs:
- _AdvancedTex0:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _AdvancedTex1:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _Ramp:
m_Texture: {fileID: 2800000, guid: df4a1e363556192459af030f3e1d4e89, type: 3}
m_Scale: {x: 1, y: 1}
Expand Down Expand Up @@ -56,6 +64,12 @@ Material:
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
m_Floats:
- _AdvancedRange0: 0.62
- _Advancedfloat0: 0
- _Advancedfloat1: 0
- _Advancedfloat3: 0
- _Advancedfloat4: 0
- _Advancedfloat7: 3.21
- _enum: 2
- _float: 0.53
- _float1: 0
Expand All @@ -69,6 +83,7 @@ Material:
- _group1: 1
- _group2: 0
- _group3: 0
- _key13_PowerSlider: 0
- _key1_Float1: 0
- _key2_Float2: 0
- _key3_Float3: 0
Expand All @@ -86,6 +101,8 @@ Material:
- _toggle: 0
- _toggle1: 0
m_Colors:
- _AdvancedColor0: {r: 1, g: 1, b: 1, a: 1}
- _AdvancedColor7: {r: 1, g: 1, b: 1, a: 1}
- _color: {r: 1, g: 0, b: 0, a: 1}
- _color1: {r: 0.7, g: 0.7, b: 1, a: 1}
- _mColor: {r: 1, g: 1, b: 1, a: 1}
Expand Down
1 change: 1 addition & 0 deletions Editor/Test/SampleDrawer 1.shader
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@


[Main(Group3, _, on)] _group3 ("Group - Tex and Color Samples", float) = 0
[Advanced][Tex(Group3)] _tex_single_line ("Tex Single Line", 2D) = "white" { }
[Advanced][Tex(Group3, _color)] _tex_color ("Tex with Color", 2D) = "white" { }
[Advanced][HideInInspector] _color (" ", Color) = (1, 0, 0, 1)
[Advanced][Tex(Group3, _textureChannelMask1)] _tex_channel ("Tex with Channel", 2D) = "white" { }
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.14.0",
"version": "1.14.1",
"displayName": "LWGUI",
"description": "A Lightweight, Flexible, Powerful Shader GUI System for Unity.",
"keywords": [
Expand Down

0 comments on commit 580cbfc

Please sign in to comment.