Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

What is LWGUI?

2025-04-02 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)06/01 Report--

This article mainly introduces what LWGUI is, has a certain reference value, interested friends can refer to, I hope you can learn a lot after reading this article, the following let the editor take you to understand it.

For example, there are many Shader plug-ins in Unity that can often see 1000 lines of Shader but 2000 lines of ShaderGUI, and it is difficult for people who are not familiar with the GUI interface to change GUI. In order to write less code and to layout ShaderGUI more simply and flexibly, I developed this tool:

Implement custom typesetting without writing a line of ShaderGUI

Using the built-in MaterialPropertyDrawer interface and referring to the built-in Drawer implementation, it finally works after stepping on countless holes. When in use, you only need to prefix Shader Property to achieve a variety of custom ShaderGUI, write Shader while typesetting, different Shader are not related to each other. You need to add CustomEditor "JTRP.ShaderDrawer.LWGUI" at the end of the Shader. LWGUI is built into JTRP,Github:https%3A//github.com/Jason-Ma-233/JasonMaToonRenderPipeline/tree/master/Assets/JTRP/Editor/Drawer.

Function List:

/ create a folding group / group:group key. If it is not provided, use shader property name/// keyword:_ to ignore, leave it empty and _ _ for attribute name uppercase + _ ON/// style:0 off by default; 1 turn on by default; 2 turn off without toggle by default 3 No toggleMain is turned on by default (string group = ", string keyWord =", float style = 0) / / the attribute is drawn in the default form within the folding group / group: the group key of the parent folding group, and the KeyWord of the suffix KWEnum or SubToggle is supported to display Sub (string group) according to the enum.

/ n indicates that the displayed name,k is the corresponding KeyWord with a maximum of 5 groups, and the float value is the currently active KeyWord index (0-4) KWEnum (string group, string N1, string K1,... String N5, string K5)

/ / display Texture in a single line, support additional attributes / extraPropName: additional attribute names Tex (string group = "", string extraPropName = "") / / support up to 4 colors side-by-side, support HDR/HSV/// parameter: enter HSV to convert the current color to HSV color and pass it into Shader Enter "_" / color if not required: optional extra color property name/// Note: to change the parameters, you need to refresh the Drawer instance manually. Enter characters randomly in shader to cause an error and then undo to refresh the Drawer instance Color (string group, string parameter, string color2, string color3, string color4) / display float/// keyword:_ in SubToggle format as ignored Leave it empty and _ _ capitalize the attribute name + _ ONSubToggle (string group, string keyWord = "") / / same as built-in PowerSlider, nonlinear RangeSubPowerSlider (string group, float power = 1) / / same as built-in Header, and only use Title (string group, string header) with LWGUI

/ / draw float to change Render Queue [Queue]

Currently, the nesting of folding groups is not supported. Functions with Sub names generally only support display under the folding group. Functions without Sub can only be displayed outside the folding group by filling the "_" parameter with "_". In addition, Decorator is not compatible with the built-in Drawer. For example, Header should only be used on default attributes, and Title should be used on attributes modified by LWGUI, otherwise display errors may occur.

To implement your own Drawer, you can refer to JTRP\ Editor\ Drawer\ ShaderDrawer.cs. The SubDrawer class provides functionality for use with MainDrawer. Please note:

Override matchPropType to filter specific attribute types for drawing, and return false to draw by default

Rewrite DrawProp to draw properties in a custom way, and JTRP\ Editor\ Drawer\ DrawerUtility.cs provides some utility functions

The GetPropertyHeight function does not work after using EditorGUILayout.GetControlRect (). It is generally recommended to use GetControlRect without paying attention to Height.

EditorGUI.showMixedValue controls how to draw when multiple shaders are selected

When EditorGUIUtility.labelWidth = 0, MaterialEditor.GetRectAfterLabelWidth will get the desired result.

Thank you for reading this article carefully. I hope the article "what is LWGUI" shared by the editor will be helpful to you. At the same time, I also hope you will support us and pay attention to the industry information channel. More related knowledge is waiting for you to learn!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Internet Technology

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report