Skip to content

Commit

Permalink
remove Tex() Extra Property Type: Float, Range
Browse files Browse the repository at this point in the history
  • Loading branch information
JasonMa0012 committed Nov 18, 2023
1 parent aafde9c commit e634f34
Show file tree
Hide file tree
Showing 8 changed files with 41 additions and 45 deletions.
2 changes: 1 addition & 1 deletion Editor/Helper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -310,7 +310,7 @@ public static bool DrawFoldout(Rect rect, ref bool isFolding, bool toggleValue,

// Button
{
// Right Click to Context Click
// Cancel Right Click
if (Event.current.type == EventType.MouseDown && Event.current.button == 1 && rect.Contains(Event.current.mousePosition))
Event.current.Use();

Expand Down
21 changes: 14 additions & 7 deletions Editor/LWGUI.cs
Original file line number Diff line number Diff line change
Expand Up @@ -91,14 +91,10 @@ public override void OnGUI(MaterialEditor materialEditor, MaterialProperty[] pro
EditorGUI.indentLevel++;
}

// Advanced
// Advanced Header
if (propStaticData.isAdvancedHeader && !propStaticData.isAdvancedHeaderProperty)
{
var rect = EditorGUILayout.GetControlRect();
var revertButtonRect = RevertableHelper.SplitRevertButtonRect(ref rect);
var label = string.IsNullOrEmpty(propStaticData.advancedHeaderString) ? "Advanced" : propStaticData.advancedHeaderString;
propStaticData.isExpanding = EditorGUI.Foldout(rect, propStaticData.isExpanding, label);
RevertableHelper.DrawRevertableProperty(revertButtonRect, prop, this, true);
DrawAdvancedHeader(propStaticData, prop);

if (!propStaticData.isExpanding)
{
Expand Down Expand Up @@ -145,6 +141,18 @@ public override void OnGUI(MaterialEditor materialEditor, MaterialProperty[] pro
Helper.DrawLogo();
}

private void DrawAdvancedHeader(PropertyStaticData propStaticData, MaterialProperty prop)
{
var rect = EditorGUILayout.GetControlRect();
var revertButtonRect = RevertableHelper.SplitRevertButtonRect(ref rect);
var label = string.IsNullOrEmpty(propStaticData.advancedHeaderString) ? "Advanced" : propStaticData.advancedHeaderString;
propStaticData.isExpanding = EditorGUI.Foldout(rect, propStaticData.isExpanding, label);
if (Event.current.type == EventType.MouseDown && Event.current.button == 0 && rect.Contains(Event.current.mousePosition))
propStaticData.isExpanding = !propStaticData.isExpanding;
RevertableHelper.DrawRevertableProperty(revertButtonRect, prop, this, true);
Helper.DoPropertyContextMenus(rect, prop, this);
}

private void DrawProperty(MaterialProperty prop)
{
var propStaticData = perShaderData.propertyDatas[prop.name];
Expand All @@ -167,6 +175,5 @@ private void DrawProperty(MaterialProperty prop)
materialEditor.ShaderProperty(rect, prop, label);
Helper.EndProperty(this, prop);
}

}
} //namespace LWGUI
15 changes: 9 additions & 6 deletions Editor/ShaderDrawer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -612,7 +612,7 @@ public SubKeywordEnumDrawer(string group, string kw1, string kw2, string kw3, st
/// group:father group name, support suffix keyword for conditional display (Default: none)
/// extraPropName: extra property name (Default: none)
/// Target Property Type: Texture
/// Extra Property Type: Any, except Texture
/// Extra Property Type: Color, Vector
/// </summary>
public class TexDrawer : SubDrawer
{
Expand Down Expand Up @@ -663,14 +663,17 @@ public override void DrawProp(Rect position, MaterialProperty prop, GUIContent l
EditorGUI.showMixedValue = prop.hasMixedValue;
var rect = position;
var texLabel = label.text;
label.text = " ";
// label.text = " ";

MaterialProperty extraProp = lwgui.perFrameData.GetProperty(_extraPropName);
if (extraProp != null && extraProp.type != MaterialProperty.PropType.Texture)
if (extraProp != null && (
extraProp.type == MaterialProperty.PropType.Color
|| extraProp.type == MaterialProperty.PropType.Vector
))
{
RevertableHelper.FixGUIWidthMismatch(extraProp.type, editor);

var i = EditorGUI.indentLevel;
RevertableHelper.FixGUIWidthMismatch(extraProp.type, editor);
EditorGUI.indentLevel += 2;

if (extraProp.type == MaterialProperty.PropType.Vector)
_channelDrawer.OnGUI(rect, extraProp, label, editor);
Expand All @@ -680,7 +683,7 @@ public override void DrawProp(Rect position, MaterialProperty prop, GUIContent l
EditorGUI.indentLevel = i;
}

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

EditorGUI.showMixedValue = false;
}
Expand Down
14 changes: 5 additions & 9 deletions Editor/Test/SampleDrawer 1.shader
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,10 @@
[Advanced][Sub(Group2)] _Advancedfloat1 ("Advanced Float 1", float) = 0
[Advanced(Advanced Header Test)][Sub(Group2)] _Advancedfloat3 ("Advanced Float 3", float) = 0
[Advanced][Sub(Group2)] _Advancedfloat4 ("Advanced Float 4", float) = 0
[AdvancedHeaderProperty][Tex(Group2, _Advancedfloat7)] _AdvancedTex0 ("Advanced Header Property Test", 2D) = "white" { }
[Advanced][HideInInspector] _Advancedfloat7 ("Advanced Float 7", float) = 0
[Advanced][Tex(Group2, _AdvancedRange0)] _AdvancedTex1 ("Advanced Tex 1", 2D) = "white" { }
[Advanced][HideInInspector] _AdvancedRange0 ("Advanced Range 0", Range(0, 1)) = 0
[AdvancedHeaderProperty][Tex(Group2, _AdvancedColor7)] _AdvancedTex0 ("Advanced Header Property Test", 2D) = "white" { }
[Advanced][HideInInspector] _AdvancedColor7 ("Advanced Color 7", Color) = (1, 1, 1, 1)
[Advanced][Tex(Group2, _AdvancedColor0)] _AdvancedTex1 ("Advanced Tex 1", 2D) = "white" { }
[Advanced][HideInInspector] _AdvancedColor0 ("Advanced Color 0", Color) = (1, 1, 1, 1)

[Title(Channel Samples)]
[Channel] _textureChannelMask ("Texture Channel Mask (Default G)", Vector) = (0, 1, 0, 0)
Expand All @@ -55,13 +55,9 @@
[Main(Group3, _, on)] _group3 ("Group - Tex and Color Samples", float) = 0
[Advanced][Tex(Group3, _color)] _tex_color ("Tex with Color", 2D) = "white" { }
[Advanced][HideInInspector] _color (" ", Color) = (1, 0, 0, 1)
[Advanced][Tex(Group3, _float4)] _tex_float ("Tex with Float", 2D) = "white" { }
[Advanced][HideInInspector] _float4 (" ", float) = 0
[Advanced][Tex(Group3, _range)] _tex_range ("Tex with Range", 2D) = "white" { }
[Advanced][HideInInspector] _range (" ", Range(0, 1)) = 0
[Advanced][Tex(Group3, _textureChannelMask1)] _tex_channel ("Tex with Channel", 2D) = "white" { }
[Advanced][HideInInspector] _textureChannelMask1 (" ", Vector) = (0, 0, 0, 1)
// Display up to 4 colors in a single line (Unity 2019.2+)

[Advanced][Color(Group3, _mColor1, _mColor2, _mColor3)] _mColor ("Multi Color", Color) = (1, 1, 1, 1)
[Advanced][HideInInspector] _mColor1 (" ", Color) = (1, 0, 0, 1)
[Advanced][HideInInspector] _mColor2 (" ", Color) = (0, 1, 0, 1)
Expand Down
26 changes: 10 additions & 16 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -286,7 +286,7 @@ public SubKeywordEnumDrawer(string group, string kw1, string kw2, string kw3, st
/// group:father group name, support suffix keyword for conditional display (Default: none)
/// extraPropName: extra property name (Default: none)
/// Target Property Type: Texture
/// Extra Property Type: Any, except Texture
/// Extra Property Type: Color, Vector
public TexDrawer() { }
public TexDrawer(string group) : this(group, String.Empty) { }
public TexDrawer(string group, string extraPropName)
Expand All @@ -308,21 +308,15 @@ Example:

```c#
[Main(Group3, _, on)] _group3 ("Group - Tex and Color Samples", float) = 0
[Tex(Group3, _color)] _tex_color ("Tex with Color", 2D) = "white" { }
[HideInInspector] _color (" ", Color) = (1, 0, 0, 1)
[Tex(Group3, _float4)] _tex_float ("Tex with Float", 2D) = "white" { }
[HideInInspector] _float4 (" ", float) = 0
[Tex(Group3, _range)] _tex_range ("Tex with Range", 2D) = "white" { }
[HideInInspector] _range (" ", Range(0,1)) = 0
[Tex(Group3, _textureChannelMask1)] _tex_channel ("Tex with Channel", 2D) = "white" { }
[HideInInspector] _textureChannelMask1(" ", Vector) = (0,0,0,1)

// Display up to 4 colors in a single line (Unity 2019.2+)
[Color(Group3, _mColor1, _mColor2, _mColor3)]
_mColor ("Multi Color", Color) = (1, 1, 1, 1)
[HideInInspector] _mColor1 (" ", Color) = (1, 0, 0, 1)
[HideInInspector] _mColor2 (" ", Color) = (0, 1, 0, 1)
[HideInInspector] [HDR] _mColor3 (" ", Color) = (0, 0, 1, 1)
[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" { }
[Advanced][HideInInspector] _textureChannelMask1 (" ", Vector) = (0, 0, 0, 1)

[Advanced][Color(Group3, _mColor1, _mColor2, _mColor3)] _mColor ("Multi Color", Color) = (1, 1, 1, 1)
[Advanced][HideInInspector] _mColor1 (" ", Color) = (1, 0, 0, 1)
[Advanced][HideInInspector] _mColor2 (" ", Color) = (0, 1, 0, 1)
[Advanced][HideInInspector] [HDR] _mColor3 (" ", Color) = (0, 0, 1, 1)

```

Expand Down
Binary file modified README_CN.assets/image-20220828003507825.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 1 addition & 5 deletions README_CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -285,7 +285,7 @@ public SubKeywordEnumDrawer(string group, string kw1, string kw2, string kw3, st
/// group:father group name, support suffix keyword for conditional display (Default: none)
/// extraPropName: extra property name (Default: none)
/// Target Property Type: Texture
/// Extra Property Type: Any, except Texture
/// Extra Property Type: Color, Vector
public TexDrawer() { }
public TexDrawer(string group) : this(group, String.Empty) { }
public TexDrawer(string group, string extraPropName)
Expand All @@ -309,10 +309,6 @@ Example:
[Main(Group3, _, on)] _group3 ("Group - Tex and Color Samples", float) = 0
[Tex(Group3, _color)] _tex_color ("Tex with Color", 2D) = "white" { }
[HideInInspector] _color (" ", Color) = (1, 0, 0, 1)
[Tex(Group3, _float4)] _tex_float ("Tex with Float", 2D) = "white" { }
[HideInInspector] _float4 (" ", float) = 0
[Tex(Group3, _range)] _tex_range ("Tex with Range", 2D) = "white" { }
[HideInInspector] _range (" ", Range(0,1)) = 0
[Tex(Group3, _textureChannelMask1)] _tex_channel ("Tex with Channel", 2D) = "white" { }
[HideInInspector] _textureChannelMask1(" ", Vector) = (0,0,0,1)

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.13.6",
"version": "1.14.0",
"displayName": "LWGUI",
"description": "A Lightweight, Flexible, Powerful Shader GUI System for Unity.",
"keywords": [
Expand Down

0 comments on commit e634f34

Please sign in to comment.