A Lightweight, Flexible, Powerful Shader GUI System for Unity.
A Lightweight, Flexible, Powerful Shader GUI System for Unity.
中文 | English A lightweight, flexible, and powerful Unity Shader GUI system built to maximize material inspector productivity.
LWGUI has been proven in many large-scale commercial projects:
with concise Material Property Drawer syntax, you can build complex inspectors quickly while benefiting from a modular Drawer/Decorator extension architecture, robust MetaData lifecycle caching, a complete Ramp/Preset/Toolbar toolchain, and Timeline integration.
It significantly shortens iteration cycles while improving collaboration between artists and technical artists.
| NEW: Now supports visual editing of LWGUI Attributes in Amplify Shader Editor! You need to install ASE v1.9.9.10+ and enable Project Settings > LWGUI > ASE Integration |
The new SampleAmplifyShader can help you get started quickly! |
| A more powerful Gradient editor than UE, with support for both Shader and C# | Use Ramp Atlas to include multiple Ramps in one Texture |
| When recording material parameter animations in Timeline, automatically capture changes to Toggle's Keywords to enable switching material Keywords at runtime. | Feature-rich toolbar |
| With your sponsorship, I will update more actively. | 有你的赞助我会更加积极地更新 |
|---|---|
| paypal.me/JasonMa0012 |
Make sure your environment is compatible with LWGUI
LWGUI <1.17: Unity 2017.4+
LWGUI >=1.17: Unity 2021.3+
Open your project
Window > Package Manager > Add > Add package from git URL , enter: https://github.com/JasonMa0012/LWGUI.git
Package Manager > Add package from diskv1.9.9.10 + Project Settings > LWGUI > ASE Integration (At this point, ASE's default Custom Editor will be replaced with LWGUI.LWGUI) Create a newer or use the existing Shader
Open the Shader in the code editor
At the bottom of the Shader, before the last large bracket, add line:CustomEditor "LWGUI.LWGUI"
Completed! Start using the following powerful Drawer to easily draw your Shader GUI
…/// Draw a property with default style in the folding group
///
/// group: parent group name (Default: none)
/// Target Property Type: Any
public SubDrawer() { }
public SubDrawer(string group)
Example:
…Default result:
Then change values:
……/// Popping a menu, you can select the Shader Property Preset, the Preset values will replaces the default values
///
/// group: parent group name (Default: none)
/// presetFileName: "Shader Property Preset" asset name, you can create new Preset by
/// "Right Click > Create > LWGUI > Shader Property Preset" in Project window,
/// *any Preset in the entire project cannot have the same name*
/// Target Property Type: Float, express current keyword index
public PresetDrawer(string presetFileName) : this("_", presetFileName) {}
public PresetDrawer(string group, string presetFileName)
Example:
…Result:
The Property Value in the selected Preset will be the default value:
…Example:
[BitMask(Preset)] _Stencil ("Stencil", Integer) = 0
[BitMask(Preset, Left, Bit6, Bit5, Bit4, Description, Bit2, Bit1, Right)] _StencilWithDescription ("Stencil With Description", Integer) = 0Result:
[!CAUTION] If used to set Stencil, it will conflict with SRP Batcher! (Reproduced in Unity 2022)
SRP Batcher does not correctly handle multiple materials with different Stencil Ref values, mistakenly merging them into a single Batch and randomly selecting one material's Stencil Ref value for the entire Batch. In theory, if different materials have different Stencil Ref values, they should not be merged into a single Batch due to differing Render States.
Solution:
- Force disable SRP Batcher by setting the Material Property Block
- Place materials with the same Stencil Ref value in a separate Render Queue to ensure the Batch's Render State is correct
/// Draw a min max slider
///
/// group: parent group name (Default: none)
/// minPropName: Output Min Property Name
/// maxPropName: Output Max Property Name
/// Target Property Type: Range, range limits express the MinMaxSlider value range
/// Output Min/Max Property Type: Range, it's value is limited by it's range
public MinMaxSliderDrawer(string minPropName, string maxPropName) : this("_", minPropName, maxPropName) { }
public MinMaxSliderDrawer(string group, string minPropName, string maxPropName)
Example:
[Title(MinMaxSlider Samples)]
[MinMaxSlider(_rangeStart, _rangeEnd)] _minMaxSlider("Min Max Slider (0 - 1)", Range(0.0, 1.0)) = 1.0
/*[HideInInspector]*/_rangeStart("Range Start", Range(0.0, 0.5)) = 0.0
/*[HideInInspector]*/[PowerSlider(10)] _rangeEnd("Range End PowerSlider", Range(0.5, 1.0)) = 1.0
Result:
/// Similar to builtin IntRange()
///
/// group: parent group name (Default: none)
/// Target Property Type: Range
public SubIntRangeDrawer(string group)
………Example:
[Ramp(_, RampMap, Assets.Art, 512)] _Ramp ("Ramp Map", 2D) = "white" { }Result:
You must manually Save the edit results, if there are unsaved changes, the Save button will display yellow.
When you move or copy the Ramp Map, remember to move together with the .meta file, otherwise you will not be able to edit it again!
Example:
public class Test : MonoBehaviour
{
public LwguiGradient lwguiGradientSrgb = new LwguiGradient();
[LwguiGradientUsage(ColorSpace.Linear, LwguiGradient.ChannelMask.RGB, LwguiGradient.GradientTimeRange.TwentyFourHundred)]
public LwguiGradient lwguiGradientLinear = new LwguiGradient();
}Result:
Default display settings can be set using the LwguiGradientUsage() Attribute.
The new LWGUI Gradient Editor integrates with Unity's built-in Gradient Editor and Curve Editor, enabling more powerful features than UE's Gradient Editor.
| Editor | Description
No open issues yet, or sync has not completed.